This works in UE 5.1 & 5.2.
GetWorld()->Scene->GetRenderScene()->RayTracingScene->GetLayerSRVChecked(ERayTracingSceneLayer::Base);
In 5.3, it was replaced with GetLayerView
which does not return a FRHIShaderResourceView
. Instead, it returns a FRDGBufferSRVRef
.
GetWorld()->Scene->GetRenderScene()->RayTracingScene->GetLayerView(ERayTracingSceneLayer::Base);
Does anyone know how to get the TLAS from the FRDGBufferSRVRef
without it failing an assert? I tried using GetRHI()
, but it fails on an assert:
checkf(DebugData->bAllowRHIAccess || GRDGAllowRHIAccess,
TEXT("Accessing the RHI resource of %s at this time is not allowed. If you hit this check in pass, ")
TEXT("that is due to this resource not being referenced in the parameters of your pass."),
Name);
UPDATE: I was able to get it to work in 5.3. GetRHI()
must be called inside the render pass, otherwise it fails the assert.
FRDGBufferSRVRef layerView = GetWorld()->Scene->GetRenderScene()->RayTracingScene->GetLayerView(ERayTracingSceneLayer::Base);
if (layerView)
{
GraphBuilder->AddPass(...,
[PassParameters, layerView](FRHIRayTracingCommandList& RHICmdList)
{
// Must call GetRHI() inside the render pass like this!
PassParameters->TLAS = layerView->GetRHI();
// ..
}
}