OptiX 9.1 SER - Builtin sphere intersection reported hits

I am using OptiX 9.1 for volumetric tracing of sphere primitives. I am having difficulties in finding the correct information for the following.

I am using SER. An overview of my raygen is:

optixTraverse(...);
if (optixHitObjectIsHit())
{
    optixReorder();
    optixInvoke();
}
else if (optixHitObjectIsMiss())
{
    // Do miss stuff
}

First of all, is my SER logic correct, i.e., do I use the API correctly/according to best usage guidelines?

Second, in my closest hit program, I am trying to determine if the reported hit is front or back face (in the case of spheres I assume entry/exit point). I am using the following:

float t_hit = optixGetRayTmax();
bool is_entry = optixIsFrontFaceHit();

According to this post the builtin sphere intersection program should report the closest intersection distance. From what I understand optixGetRayTmax() will not always return a front face hit (in the case of the sphere an entry hit) but only the closest hit (which could either be an entry or an exit one).

Again according to the same post, `optixGetAttribute_0()` should return the second closest intersection distance. I am using the following in an effort to understand what hits are reported float t_hit_other = __uint_as_float(optixGetAttribute_0()) in the closest hit, but it always returns `0.0f` (I have specified 2 attributes at module creation on the host side).

What am I missing/haven’t undstood correctly? Another thing that passed my mind is that backface culling could be enabled by default. But I couldn’t find a related ray flag to use.

Thanks for your time

For SER functions instead of optixTrace, you want to place the optixReorder and optixInvoke after you did specific things for hit or miss cases inside your raygen program to get all events handled.

Example code which also uses some coherency hint bits to group invokations by shader program here: https://github.com/NVIDIA/OptiX_Apps/blob/master/apps/MDL_renderer/shaders/raygeneration.cu#L183

The post about the built-in sphere intersection behavior from 2023 you found doesn’t match the implementation inside the much newer OptiX SDK 9.1 you use anymore.

The built-in sphere intersection functions will only report front-face intersections! That has changed to match the hardware implementation in Blackwell.

See this chapter inside the OptiX SDK 9.1 Programming Guide, esp. the second one:

https://raytracing-docs.nvidia.com/optix9/guide/index.html#curves#spheres-and-the-hit-program

https://raytracing-docs.nvidia.com/optix9/guide/index.html#curves#back-face-culling

Also the OptiX SDK Release Notes should have mentioned that change in behavior.

Meaning, if you need to hit sphere backfaces, you would need to implement your own custom sphere intersection program instead. (Same if you want to handle spheres as solids instead of hollow shells in older OptiX 7/8 SDKs, like with rays starting inside a sphere but too short to ever hit its surface, which is another thread on the dedicated OptiX sub-forum.)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.