Skip to content

Commit

Permalink
fix cylinder normal
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyi-zhang authored and njroussel committed Mar 20, 2023
1 parent 283e994 commit d9ea8e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shapes/cylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class Cylinder final : public Shape<Float, Spectrum> {
Mask active) const override {
MI_MASK_ARGUMENT(active);

const Transform4f& to_world = m_to_world.value();
auto [sin_theta, cos_theta] = dr::sincos(dr::TwoPi<Float> * sample.y());

Point3f p(cos_theta, sin_theta, sample.x());
Expand All @@ -257,8 +258,8 @@ class Cylinder final : public Shape<Float, Spectrum> {
n *= -1;

PositionSample3f ps = dr::zeros<PositionSample3f>();
ps.p = m_to_world.value().transform_affine(p);
ps.n = dr::normalize(n);
ps.p = to_world.transform_affine(p);
ps.n = dr::normalize(to_world.transform_affine(n));
ps.pdf = m_inv_surface_area;
ps.time = time;
ps.delta = false;
Expand Down

0 comments on commit d9ea8e8

Please sign in to comment.