Community Tutorial: How to Create a Custom Ray Tracing Shader as a Plugin

Hi @FluffyBunnyO ,

I’m following your tutorial, but I’m running in UE5.3. When I got your example running, I kept getting a crash on RHICreateUnorderedAccessView. Internally, that function is running an assert with (!IsImmediate() || IsInRenderingThread() || IsInRHIThread()) and is failing the assert.

I updated the Test Runner actor to call FRayGenTest::BeginRendering() on the rendering thread instead of the update function using ENQUEUE_RENDER_COMMAND and this fixes the crash on BeginRendering().

FRayGenTestParams* pParams = new FRayGenTestParams();
pParams->pTest = &Test;
pParams->bInitialized = false;

ENQUEUE_RENDER_COMMAND(FRayGenTestParams) (
	[&pParams](FRHICommandListImmediate& RHICmdList)
	{
		pParams->bInitialized = pParams->pTest->BeginRendering();
		return true;
	});

In 5.3, GetLayerSRVChecked() was replaced with GetLayerView() which returns a different object. You have to call GetRHI() on while inside the render pass to get the TLAS from the LayerView object that was returned.

See this thread for more details on getting the TLAS: How to get the scene Accelerate Structure (TLAS) for custom Ray Tracing - #5 by TJ.Ashby-ARA

1 Like