Sphere intersection

In case of built in spheres, I understand that anyhit will report back/front face intersections. If the ray originated inside the sphere and the sphere is solid, then the ray is hitting the sphere but not front/back face, regardless of the length of the ray. Is it possible to get such hit information from anyhit or closesthit?

The built-in sphere intersection program only intersects with the sphere surface.
You get that with optixBuiltinISModuleGet().

It will return the closest hit intersection distance inside the optixGetRayTmax() as usual and that intersection program has a single intersection attribute register which contains the second intersection distance when there is another surface intersection with the sphere inside the ray interval, like when hitting the sphere on the front- and back-face and not at the silhouette.

What you do with that information inside the anyhit and closesthit programs is your choice.

If you’d need spheres to report intersections when, for example, the ray is inside the sphere and not reaching the sphere surface, then you would need to implement your own custom geometric primitive with a different intersection program handling that case.

Similar to what I asked here, because that wouldn’t have worked with built-in spheres.

1 Like

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