Parallel Raycast for Lidar simulation

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!

1 Like

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

2 Likes

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:

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

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…

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

2 Likes

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.

@JamesYoo82 message me at devblitzer@gmail.com ?

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

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.

5 Likes

@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?

1 Like