logo80lv
Articlesclick_arrow
Research
Talentsclick_arrow
Events
Workshops
Aboutclick_arrow
profile_loginLogIn

Voxy Plug-in for Unreal Engine 5 Now Supports Voxel Ray Casting

Saeid Gholizade shared the tool's progress.

Last year, Saeid Gholizade, programmer and developer at Pixomondo, announced Voxy – a plug-in for Unreal Engine 5 that enables a range of tools to work with voxels. All this time, he has been working on it tirelessly and has just published a post explaining what has changed.

Voxy has evolved in various aspects, such as:

  • Storing voxel data on disk
  • Generating mesh data
  • Rendering custom instance mesh
  • Voxel ray casting

To store voxel data as an asset, Saeid uses a custom volume texture with an R8G8B8A8 format and packs the data together manually. At first, he used an InstancedStaticMesh for generating mesh data, but it got problematic with larger objects, so the creator started learning how to push different processes on GPU and ended up working with Compute shaders and the Signed Distance Field.

"I wrote a compute shader with a volume size of 256x256x256, for each voxel, There is a thread running on GPU, and each thread will check an SDF function with the given shape, to see if there should be a voxel at the given position.

"The next pass is another compute shader that checks if there is a neighbor voxel in 6 directions around each voxel (left, right, up, down, front, back), for each neighbor that does not have a voxel data I allocate 4 vertex and 6 Index for later mesh buffers data, because where there is no neighbor there should be a face."

Saeid then extracts the buffer that contains the vertices and indices count and allocates all mesh buffers based on these values. 

After, he used the greedy mesh generation to merge the adjacent voxels together in an attempt to optimize the mesh data to manage more volumes. However, rendering marching cubes as an instance mesh using the LocalVertexFactory didn't work as intended, so the developer wrote his own vertex shader to handle the instance data on GPU.

With Unreal Engine 5.2 came other problems, but Saeid managed to overcome them, and now Voxy works with both 5.1 and 5.2 APIs.

"Raycasting was another thing that I should handle when I wanted to draw voxels over other voxels, so I wrote another compute shader and passed voxel data and mouse ray, with calculating the RayBoxIntersection algorithm and storing the minimum distance of intersected voxel and ray origin using InterlockedMin function, I was able to find the voxel under mouse, and a RayPlaneIntersection check found the hitting face of the voxel, and there I got the face normal."

Along the way, the artist had to solve multiple issues, but the tool seems to be working well, with improvements arriving rapidly.

Saeid is planning to finish the project by 2024, so we will have a great voxel tool for Unreal Engine 5 soon.

The creator explained the changes in detail here. Check it out and join our 80 Level Talent platform and our Telegram channel, follow us on ThreadsInstagramTwitter, and LinkedIn, where we share breakdowns, the latest news, awesome artworks, and more.

Join discussion

Comments 0

    You might also like

    We need your consent

    We use cookies on this website to make your browsing experience better. By using the site you agree to our use of cookies.Learn more