Creating a line trace GPU raytraced compute shader

Hi,

there are a few reasons the TLAS is invalid:

// we want a slight delay before we start, otherwise some resources such as the accelerated structure will not be ready
 
if(RenderTarget != nullptr && TranscurredTime>1.0f)

I’m not sure if a delay of one second is required, the duration probably depends on the complexity of the scene and its accompanying acceleration structure that needs to be build. There might also be a better way to know when the TLAS is ready to be used as SceneRendering.cpp has a few helper methods for this:

bool FViewInfo::HasRayTracingScene() const
{
	check(Family);
	FScene* Scene = Family->Scene ? Family->Scene->GetRenderScene() : nullptr;
	if (Scene)
	{
		return Scene->RayTracingScene.IsCreated();
	}
	return false;
}
 
FRHIRayTracingScene* FViewInfo::GetRayTracingSceneChecked(ERayTracingSceneLayer Layer) const
{
	check(Family);
	if (Family->Scene)
	{
		if (FScene* Scene = Family->Scene->GetRenderScene())
		{
			FRHIRayTracingScene* Result = Scene->RayTracingScene.GetRHIRayTracingScene(Layer);
			checkf(Result, TEXT("Ray tracing scene is expected to be created at this point."));
			return Result;
		}
	}
	return nullptr;
}
 
FRDGBufferSRVRef FViewInfo::GetRayTracingSceneLayerViewChecked(ERayTracingSceneLayer Layer) const
{
	FRDGBufferSRVRef Result = nullptr;
	check(Family);
	if (Family->Scene)
	{
		if (FScene* Scene = Family->Scene->GetRenderScene())
		{
			Result = Scene->RayTracingScene.GetLayerView(Layer);
		}
	}
	checkf(Result, TEXT("Ray tracing scene SRV is expected to be created at this point."));
	return Result;
}

I hope this helps, but let me know if you have more questions.

Thanks,

Sam

[Attachment Removed]