OptiX triangular mesh: Getting the face curvatures in the hit point

Hi,

I need to know the face curvatures in the hit point of the ray (they go into the computation of the divergence of the reflected ray; application is electromagnetic scattering). What would be the best option to determine the two face curvatures?

Thanks,

Rainer

Please explain what you mean with two face curvatures and what input data you have.
For example, is it enough to simply interpolate the shading normals but you don’t have any?
Or do you need ray differentials?

Thanks for the fast reply…

I’m using a mesh with vertex normals and visually, the mesh is perfect. But for my application I need to give the rays an additional attribute, which is the ray divergence. The divergence of the reflected ray depends on the two surface curvature radii in the hit point (Wikipedia: “Curvature of surface”). Normally it is required to compute derivatives of the supporting polynomials in order to compute these radii.

I hope that my answer is sufficient…

I could try to explain the background:

I need to see a ray as a “ray tube”, so the ray / ray tube has a cross section. A pinhole camera would launch “diverging” rays, so the cross section of these launched rays increases with distance from the “eye” of the camera. In contrast, rays of an orthographic camera would not diverge (“pencil beam rays”).

When a ray hits a planar surface, it’s divergence would not change. But for example when a ray hits a convex surface (a sphere, for example), the reflected ray would diverge, the cross section of the reflected ray would increase with distance from the hit point.

For electromagnetics, I do not use the camera to generate the image. The camera launches rays and we compute a scattered field by integration over the footprints of the rays at the hit points (projected cross sectional areas of the rays at the hit points). So I think the camera launches rays and copies / adds scattered field contributions of the rays (from the “PerRayData”) into a buffer.

As mentioned, I need the face curvature radii at the hit point in order to determine the divergence of the reflected ray. Examples for face curvatures: The face radii of a planar surface are infinite, the radii of a spherical surface equal the radius of the sphere.

Yes and I want to use a triangular mesh with vertex normals to describe the geometry. I think that OptiX already has the necessary information internally because OptiX is able to interpolate the vertex normals.

Last things first: OptiX doesn’t have that information. You interpolate the normals yourself inside the intersection program, in case of triangles by using the barycentric coordinates and the given per-vertex normal attributes.

That divergence would happen automatically when shooting many rays. The different normals per hit point will automatically affect the continuation ray directions to diverge depending on the curvature without even knowing its radii, even if the ray generation used parallel rays to begin with.

What you’re asking for are basically the derivatives of the normals (dNdu, dNdv) which can be used to calculate the curvature radii.
These can be calculated with ray differentials. That requires changes to the per-ray payload and throughout all OptiX device programs to maintain that.
If you had the “projected cross sectional areas of the rays at the hit points” already, then you’d be almost there.

The OptiX SDK 3.9.1 had an example for ray differentials for a small number of primitive types in a simple way on texture coordinates to do mip-mapping.

For a more elaborate discussion about ray differentials maybe take a look at the “Physically Based Rendering” book http://www.pbrt.org/.
The link to the source code on github is on that page as well. Search for “RayDifferential” inside that codebase to get an idea of what’s required.

Many thanks!!!

Update:

I have modified / extended the OptiX mesh class to deal with Bezier triangle control points. I have implemented analytical dr/du and dr/dv derivatives (so I’m not using the ray differentials) and I compute the ray-triangle-intersection using Newton’s method with analytical derivative matrix. It works; naturally, it is somewhat slower than the original intersection.