@@ -12,21 +12,16 @@ layout(binding = 0) uniform sampler2D texColor;
1212out vec4 outColor;
1313
1414const float lumaThreshold = 0.5 ;
15- const float mulReduce = 1.0 / 8.0 ;
16- const float minReduce = 1.0 / 128.0 ;
17- const float maxSpan = 8.0 ;
15+ const float mulReduce = 1 / 8.0 ;
16+ const float minReduce = 1 / 128.0 ;
17+ const float maxSpan = 8 ;
1818const vec3 toLuma = vec3 (0.299 , 0.587 , 0.114 );
1919
2020void main()
2121{
22- vec2 texelStep = 1.0 / vec2 (textureSize(texColor, 0 ));
22+ vec2 texelStep = 1 / vec2 (textureSize(texColor, 0 ));
2323 vec2 uv = gl_FragCoord .xy * texelStep;
2424 vec3 rgbM = textureLod(texColor, uv, 0 ).rgb;
25- if (false)
26- {
27- outColor = vec4 (rgbM, 1.0 );
28- return ;
29- }
3025
3126 vec3 rgbNW = textureLodOffset(texColor, uv, 0 , ivec2 (- 1 , 1 )).rgb;
3227 vec3 rgbNE = textureLodOffset(texColor, uv, 0 , ivec2 (1 , 1 )).rgb;
@@ -41,28 +36,25 @@ void main()
4136 float lumaMax = max (lumaM, max (max (lumaNW, lumaNE), max (lumaSW, lumaSE)));
4237 if (lumaMax - lumaMin <= lumaMax * lumaThreshold)
4338 {
44- outColor = vec4 (rgbM, 1.0 );
39+ outColor = vec4 (rgbM, 1 );
4540 return ;
4641 }
4742
4843 vec2 samplingDirection;
4944 samplingDirection.x = - ((lumaNW + lumaNE) - (lumaSW + lumaSE));
5045 samplingDirection.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
5146 float samplingDirectionReduce = max ((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * mulReduce, minReduce);
52- float minSamplingDirectionFactor = 1.0 / (min (abs (samplingDirection.x), abs (samplingDirection.y)) + samplingDirectionReduce);
47+ float minSamplingDirectionFactor = 1 / (min (abs (samplingDirection.x), abs (samplingDirection.y)) + samplingDirectionReduce);
5348 samplingDirection = clamp (samplingDirection * minSamplingDirectionFactor, vec2 (- maxSpan), vec2 (maxSpan)) * texelStep;
54- vec3 rgbSampleNeg = textureLod(texColor, uv + samplingDirection * (1.0 / 3.0 - 0.5 ), 0 ).rgb;
55- vec3 rgbSamplePos = textureLod(texColor, uv + samplingDirection * (2.0 / 3.0 - 0.5 ), 0 ).rgb;
49+ vec3 rgbSampleNeg = textureLod(texColor, uv + samplingDirection * (1 / 3.0 - 0.5 ), 0 ).rgb;
50+ vec3 rgbSamplePos = textureLod(texColor, uv + samplingDirection * (2 / 3.0 - 0.5 ), 0 ).rgb;
5651 vec3 rgbTwoTab = (rgbSamplePos + rgbSampleNeg) * 0.5 ;
57- vec3 rgbSampleNegOuter = textureLod(texColor, uv + samplingDirection * (0.0 / 3.0 - 0.5 ), 0 ).rgb;
58- vec3 rgbSamplePosOuter = textureLod(texColor, uv + samplingDirection * (3.0 / 3.0 - 0.5 ), 0 ).rgb;
52+ vec3 rgbSampleNegOuter = textureLod(texColor, uv + samplingDirection * (0 / 3.0 - 0.5 ), 0 ).rgb;
53+ vec3 rgbSamplePosOuter = textureLod(texColor, uv + samplingDirection * (3 / 3.0 - 0.5 ), 0 ).rgb;
5954 vec3 rgbFourTab = (rgbSamplePosOuter + rgbSampleNegOuter) * 0.25 + rgbTwoTab * 0.5 ;
6055 float lumaFourTab = dot (rgbFourTab, toLuma);
6156 if (lumaFourTab < lumaMin || lumaFourTab > lumaMax)
62- outColor = vec4 (rgbTwoTab, 1.0 );
57+ outColor = vec4 (rgbTwoTab, 1 );
6358 else
64- outColor = vec4 (rgbFourTab, 1.0 );
65-
66- if (false)
67- outColor.r = 1.0 ;
59+ outColor = vec4 (rgbFourTab, 1 );
6860}
0 commit comments