Abstractly, the SBT-GAS-Index is a way to get one or more SBT entries for each build input.
Conceptually you need an SBT entry for at least every combination of geometry primitive type (triangle, sphere, curve, etc.) and material type that you use in your scene. Since currently each build input is a single geometry type, the build input can be a decent proxy for geometry+material combinations.
For example, if you have 3 materials and 3 different geometry types in your scene, and all 3 materials could be applied to all 3 geometry types, then you might need as many as 3*3=9 SBT entries. But if one of your geometries is curves, and the curves only accept a single hair material, then you might avoid creating every combination of geo type and mat type, and instead assign an SBT entry to only the combinations you actually use. Sometimes build inputs are good at representing those actually used combinations. Other times, you might need per-GAS or per-build-input attributes because you want visual changes for each build input. SBT-GAS-Index gives you the ability to address both of those cases.
The SBT is intentionally made very flexible so that you can choose how you want to organize it for your application, but this does make it abstract and a little confusing at times.
Trace stride and offset are basically orthogonal to geometry & materials. All our examples use stride + offset for ray types, but you could conceivably use the stride and trace offset for something else, like swapping materials interactively or associating materials with visibility masks or other tricky rendering features.
Broadly speaking, you could think about the number of instance + geometry type + material combinations you would need for a single primary ray type, and then if you add more ray types (such as shadow rays) then you will multiply the number of ray types with the number of instance-geometry-material combinations to arrive at the total number of SBT entries you need.
Note that there are two different ways of thinking about what an SBT entry even means, because an SBT entry represents (1) the shader programs that OptiX will call when a ray intersects something (or misses) and (2) the data you can access inside those shader programs that OptiX calls - the SBT record data. The way that you create and use your SBT depends on whether you need (2), the SBT record data. Initially we advised putting per-instance data in the SBT record, which will cause you to have to create a new set of SBT entries per instance, but that can sometimes get unwieldy and cause the SBT to grow too large, so in that case we recommend storing per-instance data outside of the SBT. If you limit your SBT to only geometry+material+rayType combinations, you can get closer to having one SBT entry for each set of unique hitgroup functions in your code.
–
David.