It turns out, getting the material parameters is not too complicated as Unreal can do most of the heavy lifting. This plugin on GitHub is an excellent example, although some changes need to be made for it to work in 5.6.
See the file RTXLidarComponent.cpp. Here are the key points that make it work:
- They use two delegates
FGlobalIlluminationPluginDelegates::PrepareRayTracing()
andFGlobalIlluminationPluginDelegates::RenderDiffuseIndirectLight()
, registered inURTXLidarComponent::Startup()
PrepareRayTracing
registers the ray gen shader in Unreal’s material ray tracing pipeline.RenderDiffuseIndirectLight
is the actual render pass. After registering the RGS inPrepareRayTracing
,View.MaterialRayTracingData
will contain the pipeline state and SBT that need to be passed toRayTraceDispatch
in order for the RGS to be invoked in Unreal’s material ray tracing pipeline.
Some more notes:
- For these delegates to be invoked at all, Dynamic Global Illumination needs to be set to “Plugin” in the project settings.
- The
PostOpaqueRenderDelegate
used in the tutorial does not work with this. UseRenderDiffuseIndirectLight
instead. - A lot of the manual setup done in the tutorial is not actually necessary. What really needs to be done in the render pass is setting the shader parameters, calling the dispatch function and writing the result to a render target.