It looks like there’s no render target support for volume textures. I was thinking about setting the values in a 3D texture at runtime based on some low resolution voxel data controlled by the real world.
The values would be driven by the character exploring different parts of the world for an automap similar to Doom 2016/Eternal. As I render the automap geometry, I’d also pass in the 3D volume texture into the material and fade out world coordinates if they are in the areas of the 3D texture marked as unexplored.
This would also be very similar to using a signed distance field.
If this is impossible, I could always use a 2D render target and make use of some fancy math as I draw to and sample the map.
The volumetrics plugin that ships with Unreal has an example of this, essentially it builds a pseudo-volume texture in a regular render target instead of a “real” volume texture.
From what i understand though, it is slower to use than a real Volume Texture, which is a feat in itself because capturing a volume texture at any useful resolution in realtime is already insanely slow. Also you also can’t generate mipmaps…
The example is the “Voxelize Meshes” map in the volumetrics plugin content folder
I actually just saw that UE5 has volume render targets creatable as assets in the right click menu under “Textures” so it’ll probably be possible.
I’ve been thinking of all sorts of ways to store just a single bit in some way and read it back but I’m not sure how easy that actually is since texture data is all read back as floats. Maybe I am actually OK with a 3D grayscale voxel since I can have softer edges more easily.
I’m OK without mipmapping for this, I think. In fact it might end up using more memory if I did have mipmaps.
I also saw Texture 2D array and 2D Array Render Targets which seem similar to volume textures and I can enter depth in addition to width and height.
I currently don’t see functions for drawing to those like I do with render target 2D and “Draw material to render target” Maybe there are some C++ apis though since materials are all about drawing to a 2D surface. Maybe there’s some fancy kernel stuff going on where I can draw a 3D sphere into a voxel.
I have seen pseudo volume textures too which existed before volume textures. I may think about those some more too like you suggested. Or I can hold out a bit longer and see if this support becomes more usable in UE5.
Ahhh thats awesome! I didn’t see that. Makes sense, iirc someone at Epic said they saw volumetrics as playing a big role in “next gen” effects.
Honestly if you have time I’d suggest you check it out regardless as it’s pretty straightforward and might be fast enough for what you need. Ryan Brucks has a blog post on the topic, it explains how it’s set up in the volumetrics plugin and it’s actually relatively easy to work with, all the heavy lifting is done by the EncodeVolumeCoordinates and VolumeTextureFunction functions, which are both already included.
My guess is that it would probably be part of Niagara, you can create/manipulate render targets inside of Niagara and I would guess it’s probably faster than exposing it to BP.
In fact if I had to guess, I’d say it’s what they’re using as part of their flip fluid sim in the Niagara Fluids plugin… may also be worth checking that out
Edit3: Looks like it it is indeed being used for the Niagara Flip Fluids! Found a few Grid3D modules that write to volume render targets!
Unfortunately the actual module content is all way over my head, I have no idea how any of this works but you may be able to parse it. I’ll have to look through their Grid2D+RT in the sample content and see if I can apply it to 3D. Either way, it looks really promising!
I imagine they’ll document it better once UE5 is fully out and explain how to use it. Currently the docs say no volume render targets even exist.
I’m actually pretty confident this idea of using a volume texture would work well. I thought about it some more for how to make this optimized and not just have a giant volume texture for the entire world.
Volume textures can get allocated on demand per chunk of world you explore. The chunks themselves could be something like 5k x 5k x 5k units, and each volume cell could be something like 500x500x500 units. This means you need 10x10x10 3d volume textures. I could even push things more and have larger chunks or smaller sub cells in chunks since that’s tiny. Maybe I can easily get away without even using volume textures if it’s this undemanding.
There will be a rule that any automap geometry can’t be bigger than a chunk that is representable by a volume texture and my material will take 8 volume textures in as a paremeter since that’s the worst case scenario if some object overlaps multiple cells. Then the material will use those volume textures to alpha mask the fragments in world space.
I’ll have to check out this idea of using niagara for possibly rendering in 3D.