Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix orennayarbrdf.cpp: no longer try to normalizes zero vectors. #2910

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/appleseed/renderer/modeling/bsdf/orennayarbrdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,15 @@ namespace

// Project outgoing and incoming vectors onto the tangent plane
// and compute the cosine of the angle between them.
const Vector3f V_perp_N = normalize(project(outgoing, n));
const Vector3f I_perp_N = normalize(incoming - n * cos_in);
// Do not use normalize() as V_perp and I_perp can be zero.
const Vector3f V_perp = project(outgoing, n);
const Vector3f I_perp = incoming - n * cos_in;
const float V_perp_norm = norm(V_perp);
const float I_perp_norm = norm(I_perp);
if (V_perp_norm == 0.0f || I_perp_norm == 0.0f)
return;
const Vector3f V_perp_N = V_perp / V_perp_norm;
const Vector3f I_perp_N = I_perp / I_perp_norm;
const float delta_cos_phi = dot(V_perp_N, I_perp_N);

// Compute C1 coefficient.
Expand Down