3. Implementation of Mixed Precision Ray Tracing with Embree

To apply the mixed-precision approach with Embree, custom definitions of both the underlying geometry primitives and ray definitions are required. First, user-defined double precision primitives are generated with the triangles from the Mesh Oriented datABase (MOAB). With the understanding that the values of the bounding boxes for each primitive would be interpreted by Embree in single precision, the bounds are artificially extended enough to ensure that any ray-box intersection that would have occurred in double precision would also occur in single precision, but not enough to degrade performance of the BVH traversal due to large overlaps of sibling bounding boxes. A robust box exapansion value is calculated for each volume based on the extent of the vertices making up the triangles of the volume. The following formula is applied to determine the extension value (\(\epsilon\)) of boxes for each volume:

(1)\[\epsilon = \sqrt{3} d_{max} 10^{-FLT\_DIG}\]

where \(d_{max}\) is the maximum distance a ray can travel in the volume and \(FLT\_DIG\) is the number of floating point digits supported on the machine.

Extended Embree structures for mixed precision ray tracing.

To enable double precision ray definitions and intersection distances in and out of the interface, a dual ray approach was employed. This approach extends the RTCRay and RTCHit data structures in Embree to include double precision duals of the ray origin, direction, and intersection distance (see ray_dual). During traversal, the single precision versions of the ray origin and direction are used to traverse Embree’s BVH. When a leaf node of the BVH is reached, the primitives of the leaf are intersected in double precision using the same Plücker intersection test [Platis2003] that is used in MOAB to ensure the same intersection distance (dtfar) and primitive normal (dNg_x, dNg_y, dNg_z) are returned. The single precision values for the intersection distance (tfar) and primitive normal (Ng_x, Ng_y, Ng_z) are also updated so that occluded or distant branches of the BVH will not be traversed. Values of the primID and geomID are updated as usual as the intersected primitive is updated. These two values are used to lookup the triangle and surface hit in the MOAB mesh.