-
Notifications
You must be signed in to change notification settings - Fork 421
Fixed robust node intersection for parallel rays #589
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -539,15 +539,40 @@ namespace embree | |||||||||||||||||||||||||||||||||||||||||||
| template<int N> | ||||||||||||||||||||||||||||||||||||||||||||
| __forceinline size_t intersectNodeRobust(const typename BVHN<N>::AABBNode* node, const TravRay<N,true>& ray, vfloat<N>& dist) | ||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearX = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearX)) - ray.org.x) * ray.rdir_near.x; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearY = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearY)) - ray.org.y) * ray.rdir_near.y; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearZ = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearZ)) - ray.org.z) * ray.rdir_near.z; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarX = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farX )) - ray.org.x) * ray.rdir_far.x; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarY = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farY )) - ray.org.y) * ray.rdir_far.y; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarZ = (vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farZ )) - ray.org.z) * ray.rdir_far.z; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> lowerX = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearX)); | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> lowerY = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearY)); | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> lowerZ = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.nearZ)); | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> upperX = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farX )); | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> upperY = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farY )); | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> upperZ = vfloat<N>::load((float*)((const char*)&node->lower_x+ray.farZ )); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearX0 = (lowerX - ray.org.x) * ray.rdir_near.x; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearY0 = (lowerY - ray.org.y) * ray.rdir_near.y; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tNearZ0 = (lowerZ - ray.org.z) * ray.rdir_near.z; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarX0 = (upperX - ray.org.x) * ray.rdir_far.x; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarY0 = (upperY - ray.org.y) * ray.rdir_far.y; | ||||||||||||||||||||||||||||||||||||||||||||
| const vfloat<N> tFarZ0 = (upperZ - ray.org.z) * ray.rdir_far.z; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> parX = ray.dir.x == vfloat<N>(0.0f); | ||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> parY = ray.dir.y == vfloat<N>(0.0f); | ||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> parZ = ray.dir.z == vfloat<N>(0.0f); | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> outX = parX & ((ray.org.x < lowerX) | (ray.org.x > upperX)); | ||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> outY = parY & ((ray.org.y < lowerY) | (ray.org.y > upperY)); | ||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> outZ = parZ & ((ray.org.z < lowerZ) | (ray.org.z > upperZ)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+556
to
+562
|
||||||||||||||||||||||||||||||||||||||||||||
| const vbool<N> parX = ray.dir.x == vfloat<N>(0.0f); | |
| const vbool<N> parY = ray.dir.y == vfloat<N>(0.0f); | |
| const vbool<N> parZ = ray.dir.z == vfloat<N>(0.0f); | |
| const vbool<N> outX = parX & ((ray.org.x < lowerX) | (ray.org.x > upperX)); | |
| const vbool<N> outY = parY & ((ray.org.y < lowerY) | (ray.org.y > upperY)); | |
| const vbool<N> outZ = parZ & ((ray.org.z < lowerZ) | (ray.org.z > upperZ)); | |
| const vfloat<N> minX = min(lowerX, upperX); | |
| const vfloat<N> maxX = max(lowerX, upperX); | |
| const vfloat<N> minY = min(lowerY, upperY); | |
| const vfloat<N> maxY = max(lowerY, upperY); | |
| const vfloat<N> minZ = min(lowerZ, upperZ); | |
| const vfloat<N> maxZ = max(lowerZ, upperZ); | |
| const vbool<N> parX = ray.dir.x == vfloat<N>(0.0f); | |
| const vbool<N> parY = ray.dir.y == vfloat<N>(0.0f); | |
| const vbool<N> parZ = ray.dir.z == vfloat<N>(0.0f); | |
| const vbool<N> outX = parX & ((ray.org.x < minX) | (ray.org.x > maxX)); | |
| const vbool<N> outY = parY & ((ray.org.y < minY) | (ray.org.y > maxY)); | |
| const vbool<N> outZ = parZ & ((ray.org.z < minZ) | (ray.org.z > maxZ)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still evaluates
(bound - org) * rdirfor parallel lanes, so the original0 * infinvalid operation (and resulting NaN) can still be produced before being overwritten byselect. If the goal is to fully avoid generating NaNs / FP invalid exceptions (e.g., when FP exceptions/status flags matter), consider masking the operands before the multiply forpar*lanes (e.g., adjust the delta and/or reciprocal direction for parallel lanes) so the multiply never computes0 * infin the first place.