From 4244676ba104c23e23e8092627002526cfe11436 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 5 Mar 2022 11:31:58 +0100 Subject: [PATCH] Shade "back sides" the same as "front sides" The shader used to shade the "back side" of a face, as defined by the vertex normal, differently than the front sides. This minimally invasive change removes that distinction. A surface normal is still needed for shading, to compute the angle between the surface and the light, but the direction of that normal is ignored. Close #173 --- src/graphics/shader.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/shader.wgsl b/src/graphics/shader.wgsl index 89588cf98..cdd201ad4 100644 --- a/src/graphics/shader.wgsl +++ b/src/graphics/shader.wgsl @@ -35,7 +35,7 @@ let pi: f32 = 3.14159265359; fn frag_model(in: VertexOutput) -> [[location(0)]] vec4 { let light = vec3(0.0, 0.0, -1.0); - let angle = acos(dot(light, -in.normal)); + let angle = acos(abs(dot(light, -in.normal))); let f_angle = angle / (pi / 2.0); let f_normal = max(1.0 - f_angle, 0.0);