# Parallel Raycast for Lidar simulation

**URL:** <https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158>\
**Category:** Rendering\
**Tags:** unreal-engine, Ray-Tracing, UE5-0, question\
**Created:** [July 23, 2022, 1:16am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158 "2022-07-23T01:16:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fractal\_Tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fractal\_Tree](https://forums.unrealengine.com/u/Fractal_Tree)\
**Post date:** [July 23, 2022, 1:16am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/1 "2022-07-23T01:16:30Z")

</div>

Hello there,

I’m trying to explore the capabilities of Unreal Engine 5 for robotics simulation, and I’m starting to hit quite a wall with regard to the simulation of a Lidar sensor.

My naïve implementation simply consists of casting N LineTraceSingleByChannel at the frequency of a typical Lidar (10 Hz). As one can imagine, this doesn’t scale very well with the resolution of the Lidar.  
For Lidars such as the Ouster OS0/1/2, the Velodyne Pucks/HDL32, …, this would mean calling 50k+ LineTraceSingleByChannel every 100ms.

The next step for this would be to try parallelizing these raytraces by running them on dedicated hardware in a GPU; however, the rendering stack of UE is quite obscure to me.

I’ve tried getting into the implementation of UE features that might be relevant or help me figure out where to start (Niagara particles GPU collisions, tapping into the Distance Fields used by Lumen, how Unreal’s RHI is structured, …) but the code base is so large that I’m feeling a bit lost. I’d say I’m a decent C++ programmer but I still am not familiar enough with UE to figure things out by myself just yet.

My questions:

- Would it be reasonable to try implementing the batching of raycasts on a GPU in UE5?
- If it is the case, would you have any pointers to the starting point of such a process, or an idea of the very high-level steps I would need to implement?
- If not, would there be any other solutions to this problem?

Thanks!

---

<div class="post-metadata">

**Author:** ![JamesYoo82](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamesyoo82/32/1047479_2.png) [@JamesYoo82](https://forums.unrealengine.com/u/JamesYoo82)\
**Post date:** [August 3, 2022, 1:05pm UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/2 "2022-08-03T13:05:06Z")

</div>

I am currently developing UE5 plugin for simulating Velodyne sensor and I used ‘parallefor’ function for ray-casting not GPU. Check this out!

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/8/fd8b746843bfc859fc47045a54f0c8247171f702.jpeg "Velodyne sensor plugin for UE5 (development version)") ](https://www.youtube.com/watch?v=Uf2p37seXGE)

---

<div class="post-metadata">

**Author:** ![FluffyBunnyO](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fluffybunnyo/32/692675_2.png) [@FluffyBunnyO](https://forums.unrealengine.com/u/FluffyBunnyO)\
**Post date:** [September 29, 2022, 10:31am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/3 "2022-09-29T10:31:47Z")

</div>

Ok so I might be a little bit late for the party, but I got a partial answer for you:

1. yes
2. I’m currently also searching on how to do custom ray trace shader but got stuck midway because I can’t figure several issue. pointers will be provided below
3. irrelevant

Ok so first of all you need to understand what is a ray trace shader, I suggest looking at this lecture on DirectX12 TraceRay:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/7/b07c5bedd0152715a271beab4fcf86759c0a2944.jpeg "Introduction to DirectX Raytracing") ](https://www.youtube.com/watch?v=Q1cuuepVNoY)

After that I would go and follow this tutorial on how to create a simple shader (not ray trace) to get the idea

> **[Simple compute shader with CPU readback | Community tutorial](https://dev.epicgames.com/community/learning/tutorials/WkwJ/unreal-engine-simple-compute-shader-with-cpu-readback)**
>
> In this tutorial, we'll create and dispatch our very own compute shader from C++ and BP!
> 
> This tutorial is extracted from https://unreal.shadeup.dev/doc...

it’s quite a cool one because you end up with a compute shader function that is blueprint callable

There is also this one, it even comes with the source file on gihub. though they are different from from the tutorial slightly and require some modifications to make it work (ping me if you’re getting into trouble). Also, it’s missing the .usf so… meh…

> **[Arnau Aguilar - ComputeShader UE5](https://sites.google.com/view/arnauaguilar/projects/computeshader-ue5)**
>
> Compute shaders in ue5

Now where I’m stuck at is this:  
Where do I get the accelerated structure to initialize the shader with?  
how do I define custom amount of rays?  
Can I dispatch my own rays or do I need to dispatch using the built in process in UE?  
many many more question… I wish I had an expert to talk with

---

<div class="post-metadata">

**Author:** ![Fractal\_Tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fractal\_Tree](https://forums.unrealengine.com/u/Fractal_Tree)\
**Post date:** [October 16, 2022, 12:43am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/4 "2022-10-16T00:43:12Z")

</div>

Hello and thank you both for your answers; I’ve kind of been putting that project on the shelf for a bit, but will get back to it somewhat soon; these pointers will be very helpful, I’ll make sure to check everything out.  
I’ll try to post a reply if I have any noteworthy breakthrough, and thanks a lot again.

---

<div class="post-metadata">

**Author:** ![devblitzer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@devblitzer](https://forums.unrealengine.com/u/devblitzer)\
**Post date:** [November 17, 2022, 8:09am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/5 "2022-11-17T08:09:52Z")

</div>

@JamesYoo82 message me at [devblitzer@gmail.com](mailto:devblitzer@gmail.com) ?

I am collaborating with other researchers/engineers and think you’d be interested to learn more.

---

<div class="post-metadata">

**Author:** ![FluffyBunnyO](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fluffybunnyo/32/692675_2.png) [@FluffyBunnyO](https://forums.unrealengine.com/u/FluffyBunnyO)\
**Post date:** [May 1, 2023, 5:09am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/6 "2023-05-01T05:09:09Z")

</div>

If anyone is interested, I’ve made a tutorial on how to implement a custom ray tracing shader as a plugin, this is just a basic one, but it should be rather easy to modify it to a Lidar.

> **[How to Create a Custom Ray Tracing Shader as a Plugin | Community tutorial](https://dev.epicgames.com/community/learning/tutorials/1lGL/unreal-engine-how-to-create-a-custom-ray-tracing-shader-as-a-plugin)**
>
> In this tutorial I will explain how to create a new ray tracing shader without touching the engine code.
> We will not create our own ray tracing function...

---

<div class="post-metadata">

**Author:** ![Utopia\_jp1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Utopia\_jp1](https://forums.unrealengine.com/u/Utopia_jp1)\
**Post date:** [December 11, 2023, 5:37am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/7 "2023-12-11T05:37:37Z")

</div>

@FluffyBunnyO Thank you very much for your tutorial! However, since my development environment is Linux, I can’t use DirectX. I was wondering if there’s an alternative to DirectX’s TraceRay() function in Vulkan?

---

<div class="post-metadata">

**Author:** ![FluffyBunnyO](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fluffybunnyo/32/692675_2.png) [@FluffyBunnyO](https://forums.unrealengine.com/u/FluffyBunnyO)\
**Post date:** [October 22, 2024, 10:41am UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/8 "2024-10-22T10:41:27Z")

</div>

Sorry, I’m 100% windows dev (yuck, right?) I have no idea

---

<div class="post-metadata">

**Author:** ![Leonuberuser](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Leonuberuser](https://forums.unrealengine.com/u/Leonuberuser)\
**Post date:** [September 8, 2025, 1:38pm UTC](https://forums.unrealengine.com/t/parallel-raycast-for-lidar-simulation/612158/9 "2025-09-08T13:38:30Z")

</div>

Hi, I’m also a Windows developer, and I’m currently working with UE shaders. I’d like to learn more about accessing GPU ray paths — for example, the bounce path, drawing lines of start and end points, and the flight time of ray bounces.

I’ve been able to rewrite shaders (e.g., _UnrealEngine\Engine\Shaders\Private\mushader.usf_) and retrieve certain values from UE5. However, I’m still unsure how to obtain the full bounce path.

Do you have any suggestions or recommended approaches? Thanks.
