From 5bfa731a508492ac414a5b04bd453d528777bc1a Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Mon, 10 Apr 2023 19:08:30 +0200 Subject: Param1 light and allfaces --- assets/shaders/map.wgsl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'assets/shaders/map.wgsl') diff --git a/assets/shaders/map.wgsl b/assets/shaders/map.wgsl index f6919a9..bb88a3f 100644 --- a/assets/shaders/map.wgsl +++ b/assets/shaders/map.wgsl @@ -3,11 +3,13 @@ struct VertexInput { @location(0) pos: vec3, @location(1) tex_coords: vec2, + @location(2) light: f32, } struct VertexOutput { @builtin(position) pos: vec4, @location(0) tex_coords: vec2, + @location(1) light: f32, } @group(1) @binding(0) var view_proj: mat4x4; @@ -20,6 +22,7 @@ fn vs_main( var out: VertexOutput; out.pos = view_proj * model * vec4(in.pos, 1.0); out.tex_coords = in.tex_coords; + out.light = in.light; return out; } @@ -30,5 +33,12 @@ fn vs_main( @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { - return textureSample(atlas_texture, atlas_sampler, in.tex_coords); + var color = textureSample(atlas_texture, atlas_sampler, in.tex_coords); + + if color.a < 0.1 { + discard; + } + + color = vec4(color.rgb * in.light, color.a); + return color; } -- cgit v1.2.3