5.3 Heterogeneous Volume Rendering tips and tricks

cys10107
Mon, 11 Sep 2023 10:15:04 +0000
Rendering

5.3 Heterogeneous Rendering tricks

I’ve been playing with 5.3’s Heterogeneous Volume. Here are some additional information for anyone interested, since there’s no good documentations out there yet. Feel free to correct me/add more tips!

It’s supports panoramic rendering in Movie Render Queue extra pass.
VR - Not tested
Path tracing - Should be possible as it’s mentioned in 5.3 roadmap? But I can’t get it to work.
Ray tracing - Not tested but there’s a cvar to enable it

I will refer to Heterogeneous Volumes with HV, and Sparse Volume Texture with SVT

Setting Up

I built my shader upon the one in Winbush’s tutorial, great starting point. Video Link

After Winbush’s tutorial, I recommend doing these:

1. Add some settings to shader to further art direct in Unreal
These volumes doesn’t always react to enviromental lights that well, we’ll need to add some spices for better quality

I recommend adding a static switch parameter on emission, so you can drasticly change colors on a non-fire volume. Emission color is color * density.

Opacity is usefull with custom emission. Multiply extinction and emission with Opacity param

Other dynamic effects can be added too. Useing volume local position from the shader you can map others effects onto volume. Such as custom falloff, custom emmision, etc. The only limit is our imagination.

2. Make it into a master material. You can easily change SVT asset in material instances.

3. Make it into a blueprint for easy adjustment.

Make a setup function. Create dymatic material instance and feed in material parameters in it.

Add a boolean variable “isPlaying”, make it editable in level editor

Attach your setup function to construction script and begin play. Use isPlaying to switch. If isPlaying is false, run construction script.

The reason for the last one is, somehow when I initialize static volume’s material in construction script, the volume disappears during play/render. This is the workaround I found. So make changes in Editor with isPlaying=false. When you are ready to test in level/render, set it to true. In animated VDBs it seems to render fine either way.

My full parameter list:

Some other issues/tips:

Aboud volume size
In Unreal 5.3 preview volume size is not normalized. So it would look weird at scale 1,1,1. You can find the correct size of volume in SVT asset, or in HV’s detail panel. Set the scale to the volumes accordingly. This issue is fixed in official 5.3

Transparency sorting is weird, avoid volume overlap at all costs
Volumes don’t blend. Currently these volumes sorts by volume origins (The location of HV). Meaning that if you have 2 volumes overlapping, volume behind would flash to front when you move closer to it. Placing volumes so that 1 is always further can help if overlapping is unavoidable.
You can also try turning off sorting with cvar r.HeterogeneousVolumes.DepthSort and set sorting priorities manually.

Animated VDBs doesn’t support any form of dynamic material instance. You have to use Material Parameter Collection if you want runtime adjustments. Duplicate your volume material, make a Material Parameter Collection asset of all the parameters, change all the parameters to MPC parameter, and the controll all of them using an external blueprint. This is the only workaround I found that work.

Some shader nodes have no effect
I’ve found that CameraPositionWS, ObjectPositionWS both failed to work properly, seems like they’re not passing object info into shader, which means vector transform node doesn’t work too. So if you are writing some custom effects like custom fading, you’ll need to send in camera position using BP. This is super weird and inconvenient, hopefully this changes in the future.

Cool CVars that might interest you

Some usefull performance and experimental settings are hidden in Cvars, I don’t understand all of them, but here are some usefull ones:

r.HeterogeneousVolumes.DepthSort - Turn on/off automatically depth sorting

r.HeterogeneousVolumes.HardwareRayTracing - Still doesn’t render in Path Tracer, but should work with ray tracing??

r.HeterogeneousVolumes.StepSize -1 - How far should 1 ray march step be? (Default: -1, Increase is faster/lower quality)

r.HeterogeneousVolumes.MaxStepCount - How many ray marching steps max? (Increase is slower/higher quality)

r.HeterogeneousVolumes.ShadowStepSize - How far should 1 shadow trace step be? (Default: -1. Increase is faster/lower quality)

r.HeterogeneousVolumes.MaxTraceDistance - How far should volumes render? (Render distance)

r.HeterogeneousVolumes.LightingCache.DownsampleFactor - Lighting sampling quality (Default: 0. Increase is faster/lower quality)

r.SparseVolumeTexture.Streaming.PrefetchMipLevelBias - If your animated volume is flickering and blurry, you can adjust this to force higer/lower quality load. If it can’t load fast enough it can stuck on 1 frame. This doesn’t seems to affect Movie Render Queue. (Default: 0. Increase is faster/lower quality)

Update:
Demo blueprint and material with comments.
Unzip, put the folder into your project’s content folder. Shader would have error during compile. Open the master material and assign the JangaFX VDB asset into default value.
Full Shader:

VDBDemo.zip (10.0 MB)

77 posts - 49 participants