I want to cast custom rays in order to compute something specific. I will be casting 1 ray per texture pixel, probably 1024X1024.
I’ve set up everything I need in order to do so; shader, parameters, buffers, render thread function and even the actual call for RayTrace().
I’m missing only 1 thing: the Accelerated Structure (AKA TLAS).
I’ve been searching high and low and there is a severe lack of documentation for that. I’ve found example on how to create your own TLAS, but that means using my own geometry, and not the scene’s (See RayTracingTestbed.cpp).
All the actual usages in UE get their TLAS injected as input. and when I trace it back it leads to hard coded calls and private APIs which I don’t have any access to via my plugin.
I would appreciate any help on how to find access to it.
Thanks!
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();
// ..
}
}