discard fully transparent

This commit is contained in:
griffi-gh 2024-05-06 15:52:59 +02:00
parent dd386acea1
commit f04542ac02

View file

@ -16,7 +16,7 @@ struct VertexOutput {
@builtin(position) clip_position: vec4<f32>, @builtin(position) clip_position: vec4<f32>,
@location(0) uv: vec2<f32>, @location(0) uv: vec2<f32>,
@location(1) normal: vec3<f32>, @location(1) normal: vec3<f32>,
@location(2) @interpolate(flat) tex_index: u32, @location(2) @interpolate(flat)tex_index: u32,
}; };
@vertex @vertex
@ -28,7 +28,7 @@ fn vs_main(
out.normal = in.normal; out.normal = in.normal;
out.tex_index = in.tex_index; out.tex_index = in.tex_index;
out.clip_position = camera.view_proj * vec4<f32>(in.position, 1.0); out.clip_position = camera.view_proj * vec4<f32>(in.position, 1.0);
return out; out
} }
@group(0) @binding(0) @group(0) @binding(0)
@ -39,5 +39,9 @@ var s_diffuse: sampler;
@fragment @fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(t_diffuse, s_diffuse, in.uv, in.tex_index); let color: vec4 = textureSample(t_diffuse, s_diffuse, in.uv, in.tex_index);
if (color.a == 0.) {
discard
}
color
} }