Skip to content

Commit 84e6574

Browse files
committed
Preserve input alpha
1 parent c810a07 commit 84e6574

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/materials/LuminanceMaterial.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import vertexShader from "./shaders/common.vert";
77
/**
88
* A luminance shader material.
99
*
10-
* This shader produces a greyscale luminance map that describes the absolute amount of light emitted by a scene. It can
11-
* also be configured to output colors that are scaled with their respective luminance value.
12-
*
13-
* The alpha channel always contains the luminance value.
10+
* Renders luminance, i.e. the absolute amount of light emitted by a scene.
1411
*
1512
* @see https://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9
1613
* @see https://hsto.org/getpro/habr/post_images/2ab/69d/084/2ab69d084f9a597e032624bcd74d57a7.png

src/materials/shaders/luminance.frag

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ void main() {
2424

2525
#ifdef COLOR
2626

27-
out_Color = vec4(texel.rgb * clamp(l, 0.0, 1.0), l);
27+
float mask = clamp(l, 0.0, 1.0);
28+
out_Color = vec4(texel.rgb * mask, texel.a);
2829

2930
#else
3031

31-
out_Color = vec4(l);
32+
out_Color = vec4(l, l, l, texel.a);
3233

3334
#endif
3435

0 commit comments

Comments
 (0)