Volumetric Fog feedback thread

Starting this thread for feedback and discussion about the new 4.16 Volumetric Fog feature.

Full feature description:

We now have support for Volumetric Fog. This method computes participating media density and lighting at every point in the camera frustum, so we can support varying densities and any number of lights affecting the fog.

Lighting

Volumetric Fog supports lighting from:

  • A single Directional Light, with shadowing from Cascaded Shadow Maps or static shadowing, with a Light Function
  • Any number of point and spot lights, with dynamic or static shadowing if ‘Cast Volumetric Shadow’ is enabled.
  • A single skylight, with shadowing from Distance Field Ambient Occlusion if enabled
  • Particle lights, if ‘Volumetric Scattering Intensity’ is greater than 0

Not currently supported:

  • Precomputed global illumination
  • Shadowing of Stationary skylights
  • IES profiles and Light Functions on point and spot lights
  • Shadowing from Ray Traced Distance Field Shadows
  • Shadowing from the volumetric fog itself

Translucency is properly affected by Volumetric Fog, depending on its position in the scene. By default translucency computes fog at vertices, so water planes with low tessellation can introduce artifacts. These materials can be set to compute fogging per-pixel to solve this with ‘Compute Fog Per Pixel’.

Global controls

Volumetric Fog controls are on the Exponential Height Fog Component. The exponential height distribution provides a global density for Volumetric Fog.

Scattering Distribution determines how directional the volumetric scattering is - a value of 0 means light scatters equally in all directions, while a value close to 1 causes scattering predominantly in the direction of the light (you have to be looking at the light to see its scattering).

Albedo is the overall reflectiveness of the participating media. Clouds, fog and mist, which are based on water particles, have an Albedo close to 1.

Extinction scale controls how much the participating media blocks light.

View Distance is the distance from the camera over which Volumetric Fog will be computed. There are a limited number of Z slices in the volume texture, so pushing out the View Distance will increase under-sampling artifacts near the camera.

Note that Volumetric Fog can’t really match the Exponential Height Fog in the distance, as Volumetric Fog is physically based while Exponential Height Fog is not. Properties like StartDistance, FogMaxOpacity and FogCutoffDistance don’t affect Volumetric Fog.

Each light has a ‘Volumetric Scattering Intensity’ and ‘Cast Volumetric Shadow’ setting.

Local controls

Materials using the new Volume Domain describe Albedo, Emissive and Extinction for a given point in space. Albedo is in the range [0-1] while Emissive and Extinction are world space densities with any value greater than 0.

Volume materials currently only work on particles, and only positions inside the particle radius are valid, which is usually handled by a SphereMask. The simplest Volume material for a particle system looks like this:

Placing a single-particle system with that material causes a sphere of density to be added to the Volumetric Fog. The effect is fully 3d with no billboards involved.

Multiple spherical fog particles with noise from textures can be used to limit fog to a certain area.

Temporal Reprojection

The volume textures used by Volumetric Fog are relatively low resolution and aligned to the camera frustum. Volumetric Fog uses a heavy temporal reprojection filter with a different sub-voxel jitter each frame to smooth out the aliasing. As a side effect, fast changing lights like flashlights and muzzle flashes leave lighting trails. Disable volumetric fog contribution on these lights with ‘Volumetric Scattering Intensity’ set to 0.

Performance

The GPU cost of Volumetric Fog is primarily controlled by the volume texture resolution, which is set from the Engine Shadow Scalability level. Volumetric fog costs 1ms on PlayStation 4 at High settings, and 3ms on an Nvidia 970 GTX on Epic settings, which has 8x more voxels to operate on.

Particles using the Volume domain can add significant GPU cost, depending on their 3d overdraw and instruction count. Use ‘profilegpu’ to inspect this cost.

Point and Spot lights which have ‘Cast Volumetric Shadow’ enabled cost ~3x more than unshadowed Point and Spot lights.

There was quite a bit of stuff posted about the fog in the 4.16 preview thread already, I’ll quote that here:

Posting replies to questions from the 4.16 preview thread

FogCutoffDistance is not currently supported, but I think we will in the future, for the same reason it’s useful on non-volumetric fog (separate fog on skybox vs world). See above for other unsupported settings on the exponential height fog.

Hey there @DanielW!

First off, again, huge thanks on your work here, this is truly a goldmine of useful tools that you’ve exposed for us.

Going into the localized fog via particles with the volume shader domain material, I tried utilizing this last night with a cube mesh emitter to map out a global aligned volume texture to simulate clouds, but within the cube I kept getting weird issues where the texture projection would stretch and warp depending on the camera location and angle. Additionally, the cube would only render the visible pixels up to a certain distance away from my cube emitter, and if I backed up more than a few hundred units away, the effect would appear to cull. Is this due to my use of a mesh emitter over a sprite emitter? I had assumed that the cube would be better for representing a volume, but I didn’t give sprites a go immediately, and went to bed after testing the cube emitter.

Thanks so much again for your help and for this thread, I know I’m not the only one who is super hyped on this update and these features.

Cheers!

If you increase the global density, that’s going to happen. You only notice light shafts (shadows of light) if the fog is dense enough to have everything be heavily fogged. There are two ways to have stronger light shafts without heavy global fog:

  1. Keep the global fog density low, but crank up the directional light VolumetricScatteringIntensity and put the ScatteringDistribution setting up near .9.
  2. Keep the global fog density low, but increase it in certain areas with Volume particles.

Right now volumetric fog replaces ‘Fog Inscattering Color’ within the Volumetric Fog View Distance. We might change this in the future. It’s pretty much impossible to get them to match up at the ViewDistance transition, because they are two completely different techniques.

I don’t fully understand this question. The skylight affects volumetric fog which gives an ambient term.

I haven’t figured out how that should work yet =) Source Radius doesn’t actually affect the energy emitted by our lights. I think I will end up changing the way SourceRadius works for surfaces vs Volumetrics.

You can already change a single light’s intensity on the fog with VolumetricScatteringIntensity.

It’s not hard at all to implement. Multiply would probably work better because it wouldn’t cause density to go negative. I’ll consider it.

What were your UVs? The only thing you can really use for UVs in a Volume material is WorldPosition. Right now it does some buggy voxelization of triangle meshes but I intend to change that in the future. Particle sprites are voxelized based on their radius correctly. I didn’t remember to test mesh emitters =(

This is probably because you’re getting to the end of the simulated volumetric fog range. ‘View Distance’ under ‘Volumetric Fog’ controls this distance. If you push it out, you’ll get less precision up close (more banding in details). With this technique it costs processing power or precision to cover a long view range, you pick which.

Ah that makes sense, I had been messing with the view distance values and then totally spaced it when the particle thing happened, I assumed I set up a material or particle parameter wrong. That’s what I get for waiting until 1am to test stuff.

Thanks for your insight, the cube was an editor cube so I’d assume UVs are mapped pretty typically. I’ll give it another go with sprites this evening!

How to make particles subtract from the exponential height fog instead of add?

I have tried just using negative values in any of the material outputs, but that didn’t work. There is probably some way to do it, I just didn’t find it. Probably some material function or checkbox.

So if I would have found that option, I still imagine its quite annoying though to place particles that completely fit the geometry where you want to have no fog. Like, take a very fogged city. Inside of the buildings, there should not be any fog. Is manually placing particles in the buildings that try to fill the building geometry as closely as possible really the only way to remove the fog in the buildings?

What would make more sense is to have a mesh, or lets say one or multiple convex meshes, like automatically generated (collision) from a real mesh, and say that inside of that mesh no fog should be visible. Is that possible?

If that’s not possible, even just placing “No Fog Volumes” (just an AABB like a post process volume) would be simpler than placing particles I think, and for something like buildings that would still work quite fine.

I haven’t played with the new fog yet, but is it possible to simulate the Tyndall Effect, IE: blue light gets reflected, and red/orange light gets transmitted?

I want to have very strong light shafts everywhere, just like with screen space light shafts, so I guess option 2 does not work.

I already spent hours just adjusting all the values, and I did use very low fog densities with very high VolumetricScatteringIntensity and all different kind of ScatteringDistributions, but I did not get any good result where I would see strong light shafts without everything being very fogged.

A ScatteringDistribution up near .9 also does not give strong light shafts, a setting of 0 works best there. I’m mostly interested in very strong light shafts when looking at them from the side. Similar to what I would get with placing fake lightshafts like in that blueprint demo:

https://docs.unrealengine.com/latest/images/Resources/Showcases/BlueprintExamples/BlueprintExamplesGraphicHeader.jpg

This is with a VolumetricScatteringIntensity of 400 and a fog density of 0.01:

http://puu.sh/vxjEh/11e5b8e7e1.png

Light shafts are relatively visible, but the distance and the sky is washed out, its fogged.

That’s with a VolumetricScatteringIntensity of 4000 and a fog density of 0.002:

http://puu.sh/vxjKT/ee759e470b.png

It doesn’t get any better with a higher VolumetricScatteringIntensity, increasing the VolumetricScatteringIntensity and decreasing the fog density always seems to give the exact same effect like before.

Image you would look at these screen space light shafts from the side, and they wouldn’t disappear due to being screen space:

That seems to be impossible with the new volumetric fog system.

Hi DanielW, thanks for all your work on volumetric fog - it’s :slight_smile:

Can you explain a bit more about how particle sprites trigger the fog field?

I.e. I’ve got a cloud alpha on my particles and it looks better than a flat white square but obviously the pattern itself is not visible in the fog (given its resolution).

Also, btw, distance fading in the particle shader works :slight_smile:

That’s not realistic though, since there has to be particles for the light to bounce off from, it can’t only be where the light is. You might want to check and make sure that the skylight doesn’t have volumetric lighting turned on though.

Speaking of oddball testing of the new fog, turns out beam emitters work just fine with it :slight_smile:

479a3f00d4ddd914b3bdfc936a849729191c0e4f.jpeg

Having said that, I’m a total noob with particles, so everytime I fly close enough to it that its start or end point go off screen, the whole particle effect vanishes :frowning:

Is there a way to say “Gaahhhh!!! Stay on!!! Stay on!!!”?

oh and hey, seeing how you can emit particles from the surface of skinned meshes, I guess that means we can do fog monsters now too eh?

That’s the point. It’s one of those effects which should not be realistic but cool and epic.

I mean. It can stay realistic, but there should be option to override it, to get just light shafts with minimum amount of fog. ( I guess that is what quite a bit of people expect from it).

I’m not clearly understand how it works )
It adds light color*intensity to existing fog density?
and in shadowed area it uses existing fog density or make some subtraction from it?

I feel we are missing some artistic control over the current lighting. I want the rays that are inside the arch, but I don’t want the rest of the scene to be so foggy.
Or to put it differently. I want to have a visual ray/border between light and dark area’s, but without so much fog in general. (If that makes any sense)

I tried playing around with the settings. But I didn’t get any good results without introducing a ton of “dust” to the scene.

It’s because it like in real world.
There is no lightshafts if nothing reflects light inside of it.

But you are right, this is good resquest to make shafts brighter without much of fog.