# Creating a line trace GPU raytraced compute shader 

**URL:** <https://forums.unrealengine.com/t/creating-a-line-trace-gpu-raytraced-compute-shader/2693804>\
**Category:** Architectural and Design Visualization\
**Tags:** unreal-engine, Epic-Pro-Support, question\
**Created:** [November 20, 2025, 11:19am UTC](https://forums.unrealengine.com/t/creating-a-line-trace-gpu-raytraced-compute-shader/2693804 "2025-11-20T11:19:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Sam\_Lapere](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sam\_Lapere](https://forums.unrealengine.com/u/Sam_Lapere)\
**Post date:** [December 5, 2025, 2:47am UTC](https://forums.unrealengine.com/t/creating-a-line-trace-gpu-raytraced-compute-shader/2693804/5 "2025-12-05T02:47:33Z")

</div>

Hi,

there are a few reasons the TLAS is invalid:

- the API for getting the TLAS has changed since 5.3, instead of getting it with RayTracingScene.GetLayerView(ERayTracingSceneLayer::Base), you now have to call GetRHI on the LayerView: please see [https://forums.unrealengine.com/t/community-tutorial-how-to-create-a-custom-ray-tracing-shader-as-a-plugin/1139396/5](https://forums.unrealengine.com/t/community-tutorial-how-to-create-a-custom-ray-tracing-shader-as-a-plugin/1139396/5) and [https://forums.unrealengine.com/t/how-to-get-the-scene-accelerate-structure-tlas-for-custom-ray-tracing/696723/5](https://forums.unrealengine.com/t/how-to-get-the-scene-accelerate-structure-tlas-for-custom-ray-tracing/696723/5)
- after starting BeginPlay, a delay is required before accessing the TLAS as it may not be ready yet: please see [https://forums.unrealengine.com/t/community-tutorial-how-to-create-a-custom-ray-tracing-shader-as-a-plugin/1139396/14](https://forums.unrealengine.com/t/community-tutorial-how-to-create-a-custom-ray-tracing-shader-as-a-plugin/1139396/14). The [community tutorial](https://dev.epicgames.com/community/learning/tutorials/1lGL/unreal-engine-how-to-create-a-custom-ray-tracing-shader-as-a-plugin#creatingahandlerforourshader) also adds a delay using **TranscurredTime** in **ATestRunner::Tick()** for this reason:

```auto
// 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:

```auto
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]

---

_[View the full topic](https://forums.unrealengine.com/t/creating-a-line-trace-gpu-raytraced-compute-shader/2693804)._
