In the Optix 7 examples, when
HitGroupData* rt_data = (HitGroupData*)optixGetSbtDataPointer();
is called, in the closest hit program, does rt_data point to all the meshes, or the specific mesh in which intersection happened?
In the Optix 7 examples, when
HitGroupData* rt_data = (HitGroupData*)optixGetSbtDataPointer();
is called, in the closest hit program, does rt_data point to all the meshes, or the specific mesh in which intersection happened?
Inside the SDK example HitGroupData* points to the specific hit mesh geometry data and its material information stored per shader binding table (SBT) hit record entry.
More generally the optixGetSbtDataPointer() returns the pointer to the data field in the SBT entry you defined for each of the SBT record entries (not only hit records).
https://raytracing-docs.nvidia.com/optix7/api/html/group__optix__device__api.html#gad22c11370d83cf60864422883ff9da86
https://raytracing-docs.nvidia.com/optix7/guide/index.html#shader_binding_table#sbt-record-access-on-device
Means you control what is in there. For SBT hit records you normally put the data of the indices and attributes of the hit mesh and some additional information about the material in there.
Inside the OptiX 7 examples it’s this data:
struct HitGroupData
{
GeometryData geometry_data;
MaterialData material_data;
};
template <typename T>
struct Record
{
__align__( OPTIX_SBT_RECORD_ALIGNMENT ) char header[OPTIX_SBT_RECORD_HEADER_SIZE];
T data; // optixGetSbtDataPointer() returns a pointer to this data.
};
typedef Record<RayGenData> RayGenRecord;
typedef Record<MissData> MissRecord;
typedef Record<HitGroupData> HitGroupRecord; // This is how the structure for hit records is defined.
// Search the code for "hitgroupRecordBase" and you'll see how it's built per example and what data is entered.
Thanks for the clarification. Can OptiX only access data passed through the SBT or can it access other data passed using cudaMemcpy?
Please read the whole OptiX 7 Programming Guide and work through some examples.
You can access any data passed via the SBT records or via the pipeline launch parameters.
https://raytracing-docs.nvidia.com/optix7/guide/index.html#program_pipeline_creation#pipeline-launch-parameter
Also see this post as well: https://devtalk.nvidia.com/default/topic/1065449/optix/-solved-2nd-__constant__buffer-in-optix-7-/post/5395692