5.3 Heterogeneous Volume Rendering tips and tricks

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)

24 Likes

I know these don’t cast shadows, but what about shadows inside them ? Those clouds seem to have self shadowing, but I wonder if you can get sharp shadows or rays like in the next image ? And if these don’t cast shadows maybe these won’t work so well so close to the ground ? Maybe there can be some kind of a workaround with an invisible object placed in the same position - which would cast a shadow ?

In the next image you can also see some semblance of light rays inside the vdb, because the shading is “thicker”

I also wonder if the vdb can be made as transparent and feint like in the next image ? As a sort of light mist

is it possible for you to share the whole material for 5.3? i see that you have alot more options, like SVT source and SVT animated, whats the difference? we need to use different type of SVT for animated vdbs? Would be lovely if you could share the material :slight_smile:

No, when importing you determine the number of frames of the vdb you want to import and in the asset once imported if you want to animate it. But in the shader is the same node svt sample parameter.

It’s the same. I added 2 variables because in 5.3 preview animated VDBs can’t be setup in construction script (As I mentioned in the blueprint section, but reversed), so I set up different initialization methods in BP. It’s really buggy in preview.
You can set it up the same way, I’ll clean up my code and upload a full material/blueprint after I finished project, some are just for testing and I ended up not using all of the variables.

Update with corrections:
Animated VDBs are AnimatedSparseVolumeTexture, and static VDBs are StaticSparseVolumeTexture. So you need different variable types for them in blueprint. But it’s the same reference node in shader.
Animated VDBs also need special treatment as they apparently don’t support dynamic material instance. Use Material Parameter Collection as a workaround. See updated post for more info

1 Like

For detailed shader setup, I’ll cleanup and upload blueprint and material setup when I have more time. Maybe in 1~2 weeks. I’ll answer as much as I can.

  1. About rays, unfortunately it’s not possible without some shader magic. Volume reacts to default lights, but doesn’t support light functions. It’s already pretty impressive that it support normal lights.

    You can write shaders to work around tho. Calculate a UV from sun’s vector, then animate a noise map accordingly, adjusting the opacity of the volume using that data. You can do this with custom light position too, just feed in the light location data using blueprint. I can’t figure out the math yet, but I’ll try after I have more time.

    I made a quick proof of concept using local position, meaning that rays always come from volume’s up vector, I then rotate the volume to the sun.


    Shader setup for this quick demo:

    image

  2. Yes you can! Just make the opacity parameter I described lower. The cloud in front is the same VDB with the dark clouds behind, just with low opacity and a little emission.


    By adjusting scattering color and emission shader I think it’s possible to accustom volumes to every static environment.

1 Like

Appreciate your efforts buddy!

I found another Cvar that may help with the skylight, tho its effect isn’t that much :

r.HeterogeneousVolumes.IndirectLighting 1

Also, I’m wondering how you managed to get that fluffy cloud shader (the one in the background), I’ve trying to achieve that look but increasing density will increase shadows on the other part of the cloud (I made a fake light to help enlighten it a bit)

2 Likes

You can adjust the density and the emission simultaneously to achieve “fluffiness”. I’m using an opacity parameter to control it. See updated main post for demo BP and Material, and screenshot of node setup.

1 Like

You save my day. Really helpful!
I got another question. I restarted my project and the all of heterogeneous volumes don’t show in my viewport and other objects shows broken faces or nothing but the selection boundary. I have no clue at all. any suggestion?

…other objects shows broken faces or nothing but the selection boundary.

Can you attach a screenshot? This is likely not a volume problem.

For volume disappearing, I find that re-assigning the SVT asset helps. This feature is really buggy at the moment. Lemme know if this fix it or not.

Also, see if you have “isPlaying” enabled on my blueprint. That boolean value is going to disable volume rendering in editor viewport, but shows in PIE or game.

1 Like

I tried to re-assign the instance material, but nothing changed.

Unreal 5.3 VDB test imgur link

Also, my scene is for video, not for game. Should I use BP?
Thanks for response!

Update
I creat a BP and put in my VDB mat also don’t show anything, but shows in other project.

Yes you should use BP. I’m working for a video too and using Blurprint allows me to quickly change indivisual cloud’s density, opacity, etc. Really helpful if you’re working with many volumes at once, like alot of clouds.

I really have no clue what happened to your scene. Here are some directions you can try.

  1. Wild guess. Did you turn on Heterogeneous Volume rendering in project settings?
  2. Try rebuilding the shader completely using my screenshot. Try it without my demo blueprint. Check if the shader is having problem, or the blueprint, or something else.
1 Like

I solved it!
I accidentally set R.setNearClipPlane to some kind of high value and they are all back now.
Thank you so much for any advice!
I’ll try blueprint for better controling.

1 Like

Is there a way to get heterogeneous volumes to work with ExponentialHeightFog? E.g. In this image I have the cubes mixing into the height fog but the volumes aren’t affected? Thanks!

1 Like

Hey, anyone has ideas on this?

LogSparseVolumeTextureStreamingManager: Warning: IssueRequests() SVT 0000089CC578A080 Frame 72 Mip 2: Not enough tiles available (23) to fit mip level (28) even after freeing

And that one causes crashes after saving project

Upd: helped to set tiling method to clamped in volume settings, editor stopped crashing

I found that lowering SVT LOD bias with cvar helps. But that also lowers the quality of volume. I think currently large SVTs are not loading fast enough

It is not yet supported. To solve this problem I would manually tweak scattering color and emission color, to better intergrate volumes into fog’s color.

In theory you can manually write in shader so it fades with distance, but I can’t seem to access any camera vector in shader? This is really weird. Maybe we’ll have to send in camera information using a parameter at runtime.

Hi all,

Does anyone know why in VR preview (UE5.3, Oculus Quest 2, OpenXR, via Oculus Link) a Heterogeneous Volume (smoke in this case) is rendered only in the left eye? Any help will be very much appreciated, as I don’t know how to solve it.
Regards
David - Gnomusy
PS: I attach herewith both eyes as rendered to the HMD

Thanks @cys10107, yep that’s what I’ve been doing to bluff my way with them, lifting the darker values in the material to match my atmos, and yes maybe multiplying it with distance from camera will help, but ideally one day it’ll be handled by the engine, still I’ll take what I can get for now, so much fun! Thanks for the reply!

1 Like

It is really buggy right now not gonna lie. Doesn’t seem to support VR rendering at the moment

1 Like