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 the bug about the direction of Normal. #67

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
4 changes: 2 additions & 2 deletions src/shapes/triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ bool Triangle::Intersect(const Ray &ray, Float *tHit, SurfaceInteraction *isect,
this);

// Override surface normal in _isect_ for triangle
isect->n = isect->shading.n = Normal3f(Normalize(Cross(dp02, dp12)));
isect->n = isect->shading.n = Normal3f(Normalize(Cross(dp12, dp02)));
if (mesh->n || mesh->s) {
// Initialize _Triangle_ shading geometry

Expand Down Expand Up @@ -551,7 +551,7 @@ Interaction Triangle::Sample(const Point2f &u) const {
it.n = Normalize(b[0] * mesh->n[v[0]] + b[1] * mesh->n[v[1]] +
(1 - b[0] - b[1]) * mesh->n[v[2]]);
else
it.n = Normalize(Normal3f(Cross(p1 - p0, p2 - p0)));
it.n = Normalize(Normal3f(Cross(p2 - p0, p1 - p0)));
if (reverseOrientation) it.n *= -1;

// Compute error bounds for sampled point on triangle
Expand Down