spherical-volume-rendering / svr-algorithm

A spherical volume rendering algorithm that performs ray casting through a spherical voxel grid.
Other
6 stars 7 forks source link

Simplify radialHit() logic. #131

Closed cgyurgyik closed 4 years ago

cgyurgyik commented 4 years ago

First, we can exit early if there is no intersection.

Then, since a tangential hit and a normal radial intersection are only different when calculating tStepR, we only need a boolean for that case.

To avoid branch prediction slowdown, we can simply create an array {0, -1, 1}. Since true == 1 and false == 0, we can use some quick algebra to determine the right step value.

Also uses constexpr for EPSILON values, vec3, and spherical_voxel_grid.

cgyurgyik commented 4 years ago

Thanks. Just adding a few more constexpr's to push some of the calculations to compile time rather than runtime, then I'll push it.