OptiX triangle hit face

How does OptiX determine if the built in triangle intersection happens on the front face or the back face? How does the program determine which face is front or back?

Interesting, that seems to be missing in the OptiX documentation.

That’s defined by the triangle winding. The default front face is counter-clockwise winding in a right-handed coordinate system (OpenGL), resp. clockwise in a left-handed coordinate system (DirectX).

The optixGetHitKind() result can be flipped per instance with: OPTIX_INSTANCE_FLAG_FLIP_TRIANGLE_FACING
There are three convenience functions over optixGetHitKind():
For custom primitives you have 7 bits you can set as hit kind in optixReportIntersection().

Hmm, if our ray generation point is within the scene itself(opposed to a pixel on the screen) will the output of optixIsTriangleFrontFaceHit() change with respect to change in the raygen point?

Let’s say the triangle defines an infinite plane which is splitting space into two half-spaces.
Name the two spaces front and back consistently depending on the triangle vertex order, e.g. triangle (v0, v1, v2) has the unnormalized face normal cross(v1 - v0, v2 - v0) above the front face.
Define the ray origin to lie in exactly one of these two half-spaces.
Then the ray can only hit that infinite plane (and therefore the triangle lying in it) from that space’s side, and only if the ray direction is actually pointing to that plane.

Yes, but lets assume it is a recursive raytacing program. The ray hits the triangle on one side(side A) and when queried using optixTriangleFrontFaceHit() it gives us a value( let’s assume true). When a new ray hits from the opposite side(side B), this time, will the optixTriangleBackFaceHit() return True or will Front face return true?