demotool/blur-pass.glsl

30 lines
1.1 KiB
Text
Raw Normal View History

#version 450 core
layout( location = 0 ) uniform sampler2D u_InputTexture;
layout( location = 1 ) uniform vec2 u_OutputSize;
layout( location = 2 ) uniform vec2 u_InputSize;
layout( location = 3 ) uniform int u_SourceLOD;
layout( location = 4 ) uniform vec2 u_Direction;
2017-09-30 18:30:26 +02:00
layout( location = 5 ) uniform vec4 u_Weights;
layout( location = 0 ) out vec3 color;
void main( void )
{
vec2 tmp = gl_FragCoord.xy / u_OutputSize;
2017-09-30 19:41:45 +02:00
vec2 disp = u_Direction / u_OutputSize;
2017-09-30 18:30:26 +02:00
float wt = u_Weights.x + u_Weights.y * 2 + u_Weights.z * 2 + u_Weights.w * 2;
color = u_Weights.x * textureLod( u_InputTexture , tmp , u_SourceLOD ).xyz
+ u_Weights.y * (
2017-09-30 19:41:45 +02:00
textureLod( u_InputTexture , tmp + disp , u_SourceLOD ).xyz
+ textureLod( u_InputTexture , tmp - disp , u_SourceLOD ).xyz )
+ u_Weights.z * (
2017-09-30 19:41:45 +02:00
textureLod( u_InputTexture , tmp + disp * 2 , u_SourceLOD ).xyz
+ textureLod( u_InputTexture , tmp - disp * 2 , u_SourceLOD ).xyz )
2017-09-30 18:30:26 +02:00
+ u_Weights.w * (
2017-09-30 19:41:45 +02:00
textureLod( u_InputTexture , tmp + disp * 3 , u_SourceLOD ).xyz
+ textureLod( u_InputTexture , tmp - disp * 3 , u_SourceLOD ).xyz )
2017-09-30 18:30:26 +02:00
;
color /= wt;
}