Skip to content

Commit bbb2d6a

Browse files
committed
Render black pixels as transparent
1 parent 7bcee70 commit bbb2d6a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/with_winit/src/shader.wgsl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ fn render(fragCoord: vec2<f32>, light_color: vec3<f32>) -> vec4<f32> {
9999
var light = 7.0 + 2.0 * dot(surf_normal, light_position);
100100
light = light / (0.2 * pow(length(light_position - p), 3.5));
101101

102-
return vec4<f32>(light * light_color, 1.0) * 2.0;
102+
let value = light * light_color;
103+
let is_black = (value[0] == 0.0) & (value[1] == 0.0) & (value[2] == 0.0);
104+
let alpha = select(1.0, 0.0, is_black);
105+
106+
return vec4<f32>(value, alpha) * 2.0;
103107
}
104108

105109
@fragment

0 commit comments

Comments
 (0)