Skip to content

Commit

Permalink
merian-shader: Fix ggx sampling of (0,0,-1) normal
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Dec 6, 2024
1 parent 3f25685 commit 2b80740
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/merian-shaders/bsdf_ggx.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ vec3 bsdf_ggx_VNDF_H_sample(const vec3 minuswi, const vec3 n, const float alpha,
const float y = sinTheta * sin(phi);
const vec3 cStd = vec3(x, y, z);
// reflect sample to align with normal
const vec3 up = vec3(0, 0, 1);
const vec3 wr = n + up;
const vec3 upper = vec3(0, 0, 1.0000001); // @LDAP: Changed to 1.0000001 to prevent dividing by 0.
const vec3 wr = n + upper;
const vec3 c = dot(wr, cStd) * wr / wr.z - cStd;
// compute halfway direction as standard normal
const vec3 wmStd = c + wiStd;
Expand Down

0 comments on commit 2b80740

Please sign in to comment.