Skip to content

Commit

Permalink
Normalize vector in fragment shader (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda authored Nov 27, 2023
1 parent 2d193cb commit 78b9cc1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/sample/deferredRendering/fragmentWriteGBuffers.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main(
let c = 0.2 + 0.5 * ((uv.x + uv.y) - 2.0 * floor((uv.x + uv.y) / 2.0));

var output : GBufferOutput;
output.normal = vec4(fragNormal, 1.0);
output.normal = vec4(normalize(fragNormal), 1.0);
output.albedo = vec4(c, c, c, 1.0);

return output;
Expand Down
2 changes: 1 addition & 1 deletion src/sample/shadowMapping/fragment.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main(input : FragmentInput) -> @location(0) vec4<f32> {
}
visibility /= 9.0;

let lambertFactor = max(dot(normalize(scene.lightPos - input.fragPos), input.fragNorm), 0.0);
let lambertFactor = max(dot(normalize(scene.lightPos - input.fragPos), normalize(input.fragNorm)), 0.0);
let lightingFactor = min(ambientFactor + visibility * lambertFactor, 1.0);

return vec4(lightingFactor * albedo, 1.0);
Expand Down

0 comments on commit 78b9cc1

Please sign in to comment.