topic OK , thanks for clarifying! in IntelĀ® Embree Ray Tracing Kernels
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181729#M842
<P>OK , thanks for clarifying!</P>Wed, 17 Jan 2018 16:16:43 GMTAndrewC2018-01-17T16:16:43Zuser geometry intersection routine
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181727#M840
<P>Following from the "user_geometry" example. I am mixing analytical spheres and triangulated geometry.</P>
<P>The sphere intersection function has a signature of void sphereIntersectFunc(void* spheres_i, RTCRay& ray, size_t item);</P>
<P>My algorithm simply sets up the rays, loops over them and calls</P>
<P> rtcIntersect(rtcscene, rtc_ray<I>);</I></P>
<P>In the "user defined intersection" function for the sphere(s). I notice in the <EM>passed </EM>RTCRay structure two things that I find a bit confusing.</P>
<P>- the tnear and tfar values are not 0.0 and inf as I would expect. They are often a "segment" of the ray. I can understand this may be an optimization based on a geometry space subdivision. It appears I should restrict any intersection to only be within the passed tnear and tfar.</P>
<P>- the RTCRay structure sometimes also contains a geomID == the triangulated geometry ID. That is, the ray seems to already have intersected some part of the triangulated geometry before being passed to the "sphere" intersection routine. I really don't understand this. I would expect that once a ray has intersected a geometry, it would return immediately from rtcIntersect.</P>
<P> </P>Wed, 10 Jan 2018 22:35:34 GMThttps://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181727#M840AndrewC2018-01-10T22:35:34Z1) In the user geometry
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181728#M841
<P>1) In the user geometry callback the tnear value will always be identical to the tnear initially passed to the ray, but the tfar value will shrink when hits get found. Reason is that rtcIntersect is interested in the closest hit only, and the current closest distance is recorded as ray.tfar.</P>
<P>2) rtcIntersect returns the closest intersection, thus even if it already found an intersection with a triangle, intersections with your sphere might still be closer than this current closest hit. This is why you see triangle hit data inside the ray. However, you should never read that hit data, your callback should just update the hit data (and tfar) when a closer hit is found.</P>
<P> </P>
<P> </P>Wed, 17 Jan 2018 07:46:15 GMThttps://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181728#M841SvenW_Intel2018-01-17T07:46:15ZOK , thanks for clarifying!
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181729#M842
<P>OK , thanks for clarifying!</P>Wed, 17 Jan 2018 16:16:43 GMThttps://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/user-geometry-intersection-routine/m-p/1181729#M842AndrewC2018-01-17T16:16:43Z