From e7d81ce7cc9efe59abf5c36abcf1b05eda4e57b7 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 13 May 2024 23:56:31 +0200 Subject: [PATCH] add the old "lighting" thingy --- kubi/shaders/world.wgsl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kubi/shaders/world.wgsl b/kubi/shaders/world.wgsl index ed5d35d..96b54a7 100644 --- a/kubi/shaders/world.wgsl +++ b/kubi/shaders/world.wgsl @@ -39,10 +39,20 @@ var s_diffuse: sampler; @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { - let color: vec4 = textureSample(t_diffuse, s_diffuse, in.uv, in.tex_index); + // not actual lighting; makes it easier to distinguish unlit faces + let light: f32 = + abs(in.normal.x) + .85 * + abs(in.normal.y) + .65 * + abs(in.normal.z); + + let color: vec4 = + textureSample(t_diffuse, s_diffuse, in.uv, in.tex_index) + * vec4(light, light, light, 1.0); + if (color.a < 0.5) { discard; } + return color; }