Skip to content

Commit

Permalink
fix interpolation artifacts
Browse files Browse the repository at this point in the history
NdotV could be zero because of interpolation artifacts, which would destroy the math on specular heavy material (black albedo):

see

https://gamedev.stackexchange.com/questions/67671/why-are-some-of-my-normals-facing-away-from-the-camera

a small epsilon is enough to fix it
  • Loading branch information
Uriopass committed Dec 8, 2023
1 parent 451b074 commit ab399df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion assets/shaders/pbr/render.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn calc_light(Lo: vec3<f32>,
) -> vec3<f32> {
let H: vec3<f32> = normalize(L + V);
let NdotL: f32 = max(dot(normal, L), 0.0);
let NdotV: f32 = max(dot(normal, V), 0.0);
let NdotV: f32 = max(dot(normal, V), 0.001);

let NDF: f32 = DistributionGGX(dot(normal, H), roughness);
let G: f32 = GeometrySmith(NdotV, NdotL, roughness);
Expand Down

0 comments on commit ab399df

Please sign in to comment.