Skip to content

Commit 574ec0d

Browse files
committed
Apply mask to alpha
Addresses #706
1 parent 8d509e9 commit 574ec0d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/materials/glsl/luminance.frag

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ void main() {
2727

2828
vec4 texel = texture2D(inputBuffer, vUv);
2929
float l = luminance(texel.rgb);
30+
float mask = 1.0;
3031

3132
#ifdef RANGE
3233

3334
// Apply a luminance range mask.
3435
float low = step(range.x, l);
3536
float high = step(l, range.y);
36-
37-
l *= low * high;
37+
mask = low * high;
3838

3939
#elif defined(THRESHOLD)
4040

41-
l = smoothstep(threshold, threshold + smoothing, l) * l;
41+
// Apply a high pass filter.
42+
mask = smoothstep(threshold, threshold + smoothing, l);
4243

4344
#endif
4445

4546
#ifdef COLOR
4647

47-
float mask = clamp(l, 0.0, 1.0);
48-
gl_FragColor = vec4(texel.rgb * mask, texel.a);
48+
gl_FragColor = texel * mask;
4949

5050
#else
5151

52-
gl_FragColor = vec4(l, l, l, texel.a);
52+
gl_FragColor = vec4(l * mask);
5353

5454
#endif
5555

0 commit comments

Comments
 (0)