Skip to content

Commit

Permalink
Shade "back sides" the same as "front sides"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hannobraun committed Mar 5, 2022
1 parent db8e01a commit 4244676
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/graphics/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let pi: f32 = 3.14159265359;
fn frag_model(in: VertexOutput) -> [[location(0)]] vec4<f32> {
let light = vec3<f32>(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);
Expand Down

0 comments on commit 4244676

Please sign in to comment.