I understand triangle is the built-in primitive for RT core. But if I set the OptixBuildInput.type OPTIX_BUILD_INPUT_TYPE_TRIANGLES when building GAS(means that I want to use triangle as primitive), can I define new intersection method for these triangles? I have defined a new intersection method in .cu file, but it is not called after optixLaunch.
The performance of ray-triangle intersection is great, but is the premise to use the built-in triangle intersection method?
The RTX boards will still do the BVH traversal in hardware but call back into your custom intersection program for any primitive’s AABB the ray intersects. Such a custom triangle intersection calculation will be a lot slower than the hardware intersection routine obviously.
OK great, that will help me on my way, thank you very much!
I have another question now, which confuses me lot.
I used custom geometric primitives and defined intersection program. At this time, I recorded the execution time of the optixLaunch method. Then I defined anyhit program but I did not use it, which means that I still set hitgroup_prog_group_desc.hitgroup.moduleAH and hitgroup_prog_group_desc.hitgroup.entryFunctionNameAH nullptr. I also recorded the execution time of the optixLaunch method. Curiously, the time increased a lot. I did not find out the reason. Why this happens?
There is not enough information to answer this.
Benchmarks require an explanation how you measured what exactly and absolute time results to be able to discuss them. I don’t know what “a lot” means for you.
For the measurement:
Please note that the optixLaunch call is asynchronous, like all OptiX API entry points taking a CUDA stream argument. Means you must add CUDA synchronization calls or CUDA event queries around asynchronous calls to be able to correctly measure exactly one of such calls on the host.
For the OptixProgramGroupDesc:
You would normally default-initialize all fields inside all OptixProgramGroupDesc to zero before filling them.
Means the hitgroup.moduleAH and hitgroup.entryFunctionNameAH shouldn’t have changed when explicitly setting them to nullptr.
So what exactly is the code change between the two measurements?
Did you add an OptixProgramGroupDesc with kind OPTIX_PROGRAM_GROUP_KIND_HITGROUP with all null programs?
Did you use that hitgroup inside the Shader Binding Table?
Is that unused anyhit program code inside its own module or together with all other programs?
Does your benchmark result change if you comment out the unused anyhit program code inside its module?
Maybe just post the exact code to be able to see what you programmed.