You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm a little further in my ray tracing application and now want to use the normals of the triangles to calculate the angle of incidence of a ray.
auto dirDotN=dot(rayDirection, triangle.n);
auto incidenceAngle=std::acos(dirDotN);
I discovered that the normal inside the bvh::Triangle is not normalized after it has been calculated.
I was under the impression that when a vector is used to express a direction (and a triangle's normal is such a vector), it should always be normalized...
I tried to add a normalize() call within the Triangle's constructor:
but then the triangle's intersection routine doesn't work anymore.
(I used the same test program as I did in #18, and it doesn't report any hits).
Of course, I can add another member that contains the normalized normal, but I would like to understand why the intersection routine apparently cannot cope with a normalized normal...
Could you please enlighten me on this subject?
The text was updated successfully, but these errors were encountered:
The normal stored in the triangle is here to speed up the intersection routine. It's just some precomputed data to solve the system of equations coming from the Möller-Trumbore method. It just so happens to be the cross product of two edges, which is the (not unit length) normal of the triangle. It is possible to recompute this all the time during intersections (just like it is possible to store the points on the triangle, instead of storing one vertex and two edges), but that is obviously going to incur a performance penalty. The layout chosen here is exactly the one used in Embree, for performance reasons. If you want to, you can create your own triangle primitive that only stores three points, and just recompute e1, e2, and n everytime, but I am not sure that this is less expensive than computing the real normal by normalizing n after BVH traversal.
Of course I would not want to recalculate everything every time.
I understand now that n is used internally by bvh::Triangle for performance reasons, and not supposed to be used externally for other purposes...
Hi,
I'm a little further in my ray tracing application and now want to use the normals of the triangles to calculate the angle of incidence of a ray.
I discovered that the normal inside the bvh::Triangle is not normalized after it has been calculated.
I was under the impression that when a vector is used to express a direction (and a triangle's normal is such a vector), it should always be normalized...
I tried to add a normalize() call within the Triangle's constructor:
but then the triangle's intersection routine doesn't work anymore.
(I used the same test program as I did in #18, and it doesn't report any hits).
Of course, I can add another member that contains the normalized normal, but I would like to understand why the intersection routine apparently cannot cope with a normalized normal...
Could you please enlighten me on this subject?
The text was updated successfully, but these errors were encountered: