# error when tracing ray very close to a geometry instance

**URL:** <https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719>\
**Category:** OptiX\
**Created:** [September 5, 2014, 2:27am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719 "2014-09-05T02:27:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lang](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lang](https://forums.developer.nvidia.com/u/lang)\
**Post date:** [September 5, 2014, 2:27am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/1 "2014-09-05T02:27:02Z")

</div>

In my program, i move ray origin to a hit and then trace from that position with direction unchanged.  
Sometimes, the ray should leave the geometry but optix gives a hit with t\_hit~0.001.

I’ve relaxed epsilon to 1e-4 and successfully avoided t\_hit in the order of 1e-5. But further relaxation is unacceptable.

Any ideas in treating that?  
Thanks!

---

<div class="post-metadata">

**Author:** ![nljones](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nljones/32/10329_2.png) [@nljones](https://forums.developer.nvidia.com/u/nljones)\
**Post date:** [September 5, 2014, 3:58am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/2 "2014-09-05T03:58:11Z")

</div>

This can happen due to floating point precision errors when your geometry is far away from the origin. Is there any way for you move the geometry closer to the origin?

---

<div class="post-metadata">

**Author:** ![lang](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lang](https://forums.developer.nvidia.com/u/lang)\
**Post date:** [September 5, 2014, 4:16am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/3 "2014-09-05T04:16:55Z")

</div>

I can move geometry closer if using transform node. But currently I’m making structure shallower.  
Now I suppose the unit is cm. If I transform to m, the numbers will be smaller. Is that counted as closer?

---

<div class="post-metadata">

**Author:** ![Smejkal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Smejkal](https://forums.developer.nvidia.com/u/Smejkal)\
**Post date:** [September 5, 2014, 6:32am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/4 "2014-09-05T06:32:39Z")

</div>

If you have only triangles in your intersection program, you can store object id and primitive id. When you trace from this triangle, you can ignore intersection with same object and primitive id (you can do it at the beginning of intersection program).

---

<div class="post-metadata">

**Author:** ![nljones](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nljones/32/10329_2.png) [@nljones](https://forums.developer.nvidia.com/u/nljones)\
**Post date:** [September 5, 2014, 11:43am UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/5 "2014-09-05T11:43:06Z")

</div>

> [@lang](#):
>
> If I transform to m, the numbers will be smaller. Is that counted as closer?

Possibly, but not guaranteed. Because it’s floating point arithmetic, scaling is only guaranteed to help if it changes the distance relative to the epsilon.

---

<div class="post-metadata">

**Author:** ![lang](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lang](https://forums.developer.nvidia.com/u/lang)\
**Post date:** [September 5, 2014, 1:34pm UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/6 "2014-09-05T13:34:23Z")

</div>

I transform cm to m and it helps a lot. But I still get a few wrong results.  
Another alternative is to use transform nodes. My scene aims to have thousands of cylinders, tens of which are grouped into an ‘assembly’. Now I’m using no transform node to get the shallowest structure. Is it worth putting the ‘assembly’ into a geometry group and then add to a transform node?

---

<div class="post-metadata">

**Author:** ![nljones](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nljones/32/10329_2.png) [@nljones](https://forums.developer.nvidia.com/u/nljones)\
**Post date:** [September 5, 2014, 3:16pm UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/7 "2014-09-05T15:16:00Z")

</div>

> [@lang](#):
>
> Is it worth putting the ‘assembly’ into a geometry group and then add to a transform node?

According to Table 7 from the OptiX Programming Guide, the Intersection program uses object coordinates. That suggests that using a transform node will help.

---

<div class="post-metadata">

**Author:** ![lang](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lang](https://forums.developer.nvidia.com/u/lang)\
**Post date:** [September 5, 2014, 6:55pm UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/8 "2014-09-05T18:55:12Z")

</div>

My point is whether the accuracy will be obtained at cost of performance. Programming guide also suggests against transform node to avoid deep structure.

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [June 14, 2022, 9:11pm UTC](https://forums.developer.nvidia.com/t/error-when-tracing-ray-very-close-to-a-geometry-instance/34719/9 "2022-06-14T21:11:45Z")

</div>

Closed on June 14, 2022, 9:11pm UTC


