1 of 105

F O G V O L U M E 3.4

VOLUMETRIC FOG FOR UNITY 5

2 of 105

WHAT’S

FOG VOLUME?

Fog Volume is a volumetric fog solution for Unity 5.

Flexibility is its strong point, you can render clouds, nebulas, ground mist and almost any kind of dense gas situation.

3 of 105

Downloads:

.avi

.mp4

.webm

4 of 105

FEATURES

Click the images to watch the videos

  • Light Halo
  • Self Shadows
  • In-scattering
  • Point lights
  • Volume shadows
  • Projected soft shadows
  • Cloud animation
  • Light absorption
  • Lambert Diffuse
  • Distance fields

5 of 105

DEMOS

All the scenes shown in this documentation and trailer video are included in the product and are playable from this application

Menu and camera not working with wacom tablets. No bugs in editor though.

Press Escape to exit. Xbox Gamepad compatible.

Control map:

Action

Keyboard

Gamepad

Mouse

Camera up

E

RT

Camera down

Q

LT

Look

R Stick

any mouse button drag

Camera Speed

RMB + wheel

Movement

WASD

L Stick

FOV

Z, C

RMB

Acceleration

Shift (Speed x4)

RT

FPS counter

F

6 of 105

SCENES

INFINITE CLOUD

In this case we have an example of generic cloudscape that can be used as preset or starting point.

Camera is flying through the cloud automatically.

7 of 105

SCENES

INTERIOR

PRIMITIVES

This scene shows how we can use primitives to define the noise boundaries.

We also see how GI and lights are used to light the fog

8 of 105

SCENES

SCOTLAND

This scene is using 2 volumes

  • Clouds
    • Which casts shadows
  • Ground clouds + fog
    • receives shadows
    • clouds defined with distance fields.

Light behaves in a very interesting way here. We can see dramatic changes going from sunny to cloudy without animating any parameter.

9 of 105

SCENES

LANDSCAPE

SHADOWS

The goal of this scene was to debug shadows. Clouds are quite sharp and bright. Probably a good preset for you.

The terrain is white to make the scene shadows more visible.

10 of 105

SCENES

NEBULA

Built to demonstrate the usage of point lights.

11 of 105

SCENES

PILLARS

This was the first scene using the primitive modelling feature. Inspired in “The Pillars of creation”.

12 of 105

SCENES

VENUS

ATMOSPHERE

This sample features light absorption and long - distance shadows

13 of 105

SCENES

MOONLIGHT

Night scene featuring light source halo and light absorption.�Cloud animation is especially interesting in this demo.

14 of 105

SCENES

NEBULA 3

15 of 105

SCENES

TOD TRANSITION

Animated sequence for dynamic sun rotation. Commonly known as time-of-the-day transition.

This scene is a bit more costly than a normal situation because of the cotton candy look. The cloud edges are larger than it should, and this makes this cloud more expensive . In production we would have shorter edges.

Sky background is Unity procedural sky. Clouds and fog are generated with a single Fog Volume.

16 of 105

SCENES

MOCKUP

Cubed version of the scene ‘Scotland’.

I tried to make a glass box with a living scenery inside.

As soon as the camera gets inside of the box, what was a mockup turns out into a big scale world.

17 of 105

SCENES

NEBULA 2

Variant of Nebula 3

18 of 105

SCENES

VR SHOWROOM

In this room, we will be able to see how people is using Fog Volume and play with parameters in real-time.

Hoping to see your project in the VR Showroom!

Download .EXE (windows + VIVE)

19 of 105

SCENES

FAST CLOUDS

Worried about performance?

Here is an example of a fast cloudy sky setup

20 of 105

SCENES

DENSITY BLUR 2

Simple example to demonstrate the new depth-based blur effect

21 of 105

SCENES

LANDSCAPE SHADOWS

+ DENSITY BLUR

In this case, a textured fog volume is used as density data for the camera effect.

This is not recommended because it has to be rendered twice.

22 of 105

SCENES

TREES

Uniform fog sample using the new camera blur effect

23 of 105

SCENES

STATIC

VOLUMETRIC

SHADOWS

Single fog volume for ground and atmosphere.

A second FV is located on the top side to model cirrus

24 of 105

SCENES

DYNAMIC

VOLUMETRIC

SHADOWS

Single fog volume for ground and atmosphere.

A second FV is located on the top side to model cirrus

25 of 105

WHAT’S NOT

FOG VOLUME

Fog Volume is not a sky simulator.

Albeit you can render pretty convincing clouds, it was not designed as a sky renderer system or time of the day suite.

Color won’t change with light angle.

!

26 of 105

Tutorials

27 of 105

LIMITATIONS

Fog Volume uses scene depth to correctly interact with scene objects. Transparent shaders don’t write this information, which will cause Fog Volume to ignore them. You won’t be able to sort transparent shaders inside a Fog Volume correctly. In this case, transparencies must be rendered behind or in front of the volume, not inside.

28 of 105

COMPATIBILITY

WITH UNITY FEATURES

Orthographic cameras

Editor Isometric view

Reflection probes

MSAA

Prefabs

SpeedTree

Light Probes

Proxy Volume

29 of 105

COMPATIBILITY

WITH OTHER ASSETS

PlayWay Water

30 of 105

COMPATIBILITY

WITH OTHER ASSETS

Helios

Video done with Helios capture

31 of 105

COMPATIBILITY

WITH OTHER ASSETS

AQUAS

32 of 105

COMPATIBILITY

WITH OTHER ASSETS

GAIA

As of 3.2.1, Gaia will manage Fog Volume to be added to the scene with a single click

33 of 105

PROJECT SETUP

AND REQUIRED CONTENT

The included scenes require PostProcessing Stack.

POST-PROCESSING STACK

Link

EXPLORATION CAMERA

Xbox controller support: Download the input manager file from here and copy it to \ProjectSettings

COLOR SPACE

Linear recommended. Fog Volume will look similar in both cases, but light intensity will change.

Demo content has been adjusted for linear.

PROJECT REQUIREMENTS

4 layer slots available

UPDATING

Delete all the content in Assets/FogVolume before importing.

SCENE REQUIREMENTS

1 Directional light. It can be disabled, but FV needs its rotation, color and intensity.

Make sure that the camera script is correctly loaded.

34 of 105

GETTING STARTED

CREATING A FOG VOLUME

There are several ways to create Fog Volume objects:

Gameobject > Create Other > Fog Volume

Fog Volume > Fog Volume

Create > Create Other > Fog Volume

Right click on Hierarchy > Create Other > Fog Volume

35 of 105

36 of 105

FOG TYPES

UNIFORM

This is the most basic and cheapest fog type you may get and best suited for mobile projects without blowing up the gpu :)

Parameters are very easy to understand. Here we only use visibility, size, color and in-scattering.

37 of 105

FOG TYPES

GRADIENTS

Things are now much more complex. We have Gradient activated here. This means we are now executing raymarching. You will see a new tab called Renderer. Here is where we adjust the raymarching parameters.

You may noticed that Visibility disappeared. We have now to use “Intensity” inside the Renderer tab.

Scene Collision will be activated by default. Turn it off if there aren’t objects intersecting the volume.

The softness value adjusts the intersection range. 1 by default.

Jitter is useful to hide the gap between each raymarch iteration. Don’t abuse, it makes things more expensive ;)

Sampling method defines the view ray method. You can choose between ray distance to box or view aligned planes.

Unless the camera doesn’t look around, Eye2Box will be the best choice.

Max iterations tells the raymarcher the max iterations to perform.

Iteration step size is the size between each iteration. Less space means more quality but more iterations needed to reach the end of the volume.

Draw distance is the max draw distance. The effect will fade before reaching the end at the given distance.

Height gradient and radius fade are secondary fading methods.

View mode is a debug view mode. I will be adding more debug views in the future. I will dig into this in another example.

The color parameter is now called Light Energy. With raymarch activated, this name has more sense, since we have now a light equation. This value will multiply the outgoing light.

We see now more lighting parameters. Ambient, which I set here to black and absorption to zero. Those parameters have more sense when we have noise activated.

38 of 105

FOG TYPES

NOISE

Noise has many options, and here is where performance will suffer more. Scale is the global size of the noise. It multiplies Base Tiling and Detail layer tiling. Density makes clouds more dense, affecting opacity and light absorption. Octaves represent the amount of noise layers computed. When it is set to 1 it means: 1 base layer + 1 detail layer. By default, 2 layers of noise are active. You can turn off the detail layer if Draw distance == 1. Note that the more it repeats, the more expensive it will be.

Base layer has its own intensity value; Coverage, [0, 1] and own speed.

Detail layer will only be rendered when:

  • Base layer opacity >0
  • Base layer opacity < Cutoff

This saves a lot of unnecessary work.

Masking Threshold makes a soft transition to the detail layer where it starts.

Ambient and Absorption are active for this cloudy layer. Ambient is added to the light equation and Absorption will play an important role. It is very cheap compared to other lighting options. It will darken the dense parts of the noise and brighten the edges. It will also affect In-scattering anisotropy and Halo opacity and diffusion.

In this case, lighting is a bit more complex. Directional Lighting is activated. One iteration will be enough. Distance is used to displace the lighting result and Density will increase light absorption and opacity.

Intensity and Contrast shapes the noise. To modify opacity without affecting the shape, use Density.

We need Scene Collision activated to make it intersect correctly with the mountain and trees. With Coordinates/Scroll we add a little of movement.

Jitter is activated in this case, since the gaps are more obvious when noise is activated.

Height Gradient sets a grayscale gradient from the bottom of the volume to the top given min and max values to fade noise. This shapes the cloud opacity.

39 of 105

FOG TYPES

NOISE

In this scene we don’t activate Scene Collision in clouds because they do not intersect the terrain, we must avoid unnecessary gpu work.

Height Gradient shapes the clouds making them less populated on top of the volume.

We use here 2 Octaves (2 Base + 2 detail layers). When Octaves==2, a new parameter appears: Curl. This value will reuse the Octave 1 detail to distort the second detail layer.

Swirl Deformer is used to make repetition less obvious by shaping the space coordinates with a swirl deformation.

Detail is added only at the edges of the base layer. Adjust the edge size with Trim Threshold. Trim is used to subtract base layer with detail layer. Making base layer dense with sharp edges will reduce the detail sampling area, thus less expensive.

40 of 105

FOG TYPES

NOISE: RADIUS FADE

In volumes using noise we can use a spherical range to fade the noise at the edges. This is not a very common need, so it is disabled by default in the shader to avoid shader variants. The tooltip explains how to activate it.

Activate Radius Fade and set a distance.

41 of 105

FOG TYPES

VOLUME FOG

We can fill the empty space left by noise or gradients adding fog. Activate Volume Fog and a new In-scattering module will appear in the lighting tab. The Volume Fog in-scattering works in the same way than the cloud in-scattering. It will be correctly masked when it receives shadows.

We can push this effect with Start distance and make the transition softer with Transition Wideness

Use the Ambient Color alpha to control the amount of ambient applied to the volumetric shadow.

Low visibility will make the render cheaper. Raymarch stops once an opaque pixel is drawn.

42 of 105

FOG VOLUME DATA

CAMERA SELECTION

A new object named “Fog Volume Data” will be created when there is a FV in the scene. We will manage from here what camera will be used to render Fog Volume.

If Game Camera is empty, it will search in the scene for a valid camera. If none is found, Fog Volume will be disabled until a new camera is added to the scene.

When we have several cameras in the scene we can assign any of them manually or via scripting.

Each Volume will show now the camera in use at the very bottom of the inspector. By clicking this button we will select that camera:

43 of 105

FOG VOLUME DATA

VIVE

After adding a Fog Volume, jump to Fog Volume Data and assign the eye camera:

Download sample scene

FV renderer expects to find the parent of the camera: (head)

44 of 105

STEREO CAMERA

To use a standard camera in stereo, make the game camera child of another gameObject and reset the camera transform

45 of 105

RENDERER

CAMERA SCRIPT

This script will manage the rendering in Game view.

Scene view is rendered at full resolution and performance will

be much slower compared to the Game view.

FogVolumeData.cs will assign this script to its assigned camera automatically.

Depth layers: specify the layers that will be used to generate the depth buffer (new in 3.2.1p2)

Activate depth-aware upsampling only if Scene Collision is enabled. DeNoise can be used to soften the noise caused by jitter.

46 of 105

RENDERER

DEPTH & COLLISION WITH SCENE

Depth is required when a textured Fog Volume (non uniform) intersects the scene and we use Downscale . With it enabled, we need Scene Collision active in our volume:

Camera script

Depth buffer in the scene Scotland

VIEWER

Use the prefab RT_Viewer to see the generated buffers

NOTE

Post Processing stack disables Depth generation. This will break uniform fog and Scene view collisions. Workaround: enable DOF.

CameraDepthTexture will be used when Downsampling is 0 or Camera Script is disabled. When enabled and set to 1, Fog Volume will generate its own Depth map, so Fog Volume won't need _CameraDepthTexture for textured fog (noise or gradient)

47 of 105

RENDERER

COLLISION ISSUES

Unity _CameraDepthTexture is a source of problems and there are many reasons that makes it not available.

Most common cases when running a forward camera:

  • No directional light in scene
  • Directional light without shadows enabled
  • Postprocess stack turning off camera depth generation
  • Scene View with light disabled
  • Quality settings with shadows disabled

When is _CameraDepthTexture used?

  • Fog Volume type: uniform

  • Scene View
  • Game view with FogVolumeRenderer.cs not in use

48 of 105

RENDERER

Ztest

In the case of background clouds, it will not be necessary to generate the depth buffer. Let's see how the scene “Fast Clouds” is set

Depth is disabled and we don’t activate Collision in the volumes.

But we have to modify the cloud Ztest value to make it to be rendered in the background.

49 of 105

RENDERER

Ztest

Let’s go to the scene “Fast Clouds” and select the object Fog Volume [Clouds]. Within the tab Other we will find Rendering Options and then Ztest is set to Less Equal.

This makes FV to be rendered in the background

50 of 105

RENDERER

Ztest

Ztest is set to Disabled by default

But for the scene Fast Clouds it is set to Less Equal, so it is rendered in

the background

Ztest set to LessEqual

Ztest

Ztest is hardcoded in Surrogates. Their Ztest is managed by the camera script.

51 of 105

RENDERER

Ztest

If set to Always this is what we would get.

It is seen correctly in Game viewport because the Ztest is internally managed for the surrogate.

Ztest set to Always

52 of 105

RENDERER

Ztest

In “Scotland” we can see that Ztest is set to Disabled. Always works too. In this case we want clouds that intersect the terrain, thus we activate Depth, Collision and then make them render on top with Ztest=Always (or Disabled)

Ztest set to Always

53 of 105

RENDERER

UPSAMPLING

By enabling Edge-Aware upscale we can fix the resulting artifacts from low-resolution rendering.

A bilateral upsampling filter is applied to our RT based on depth discontinuities. Enable Show edge mask to see the result of the edge detection filter and tweak Depth Threshold until the artifacts are minimal.

Edge fix and DeNoise don’t play well together because of the nature of DeNoise, which is a temporal effect

54 of 105

RENDERER

SURROGATES

We talk now about “surrogates”, which are cubes that sample the result of the offscreen render of the volumes. They are like TV screens, they just show the low-res version in the scene. This way we can sort transparencies correctly.

When we turn on downsampling, textured fog volumes won’t be visible for the assigned camera. Our game camera will render the surrogates instead.

Auto Generated surrogates are made of a copy of the original volume mesh.

Every Textured Fog Volume will generate its surrogate (by default) when Downscale >0

We can cancel the surrogate at the very bottom of the Fog Volume UI:

Auto-generated surrogates have some limitations. They are good for a quick preview though.

LIMITATION

We can’t set the draw order in automatically created surrogates

They disappear when the editor is paused

55 of 105

RENDERER

SURROGATES

In some cases, we would have to create our surrogate manually because overlapping Surrogates don’t blend well together. It’s also good for performance to have as few as possible to avoid unnecessary overdraw. Lets see some examples.�In the mockup demo we have 2 Fog Volumes. If we let them generate their surrogates, we can notice incorrect blending:

56 of 105

RENDERER

SURROGATES

Let’s create a surrogate manually instead.

Turn off Surrogates in the volumes:

57 of 105

RENDERER

SURROGATES

We will make a box that wraps the volumes.

Then, apply the following material:

Set the layer:

��

Use RenderPriority.cs if required.

58 of 105

RENDERER

SURROGATES

And we’re done

59 of 105

RENDERER

SURROGATES

We are in the same situation in the ‘Showroom’ demo. In that case I used the “Render Priority” script to make it to be drawn before the glass:

60 of 105

Ground fog receives shadows from clouds volume.

61 of 105

LIGHTING

VOLUME

SHADOWS

Shadow caster

Go to the mesh renderer and set Cast Shadows ON

The shadow caster will show then some more options in the lighting tab:

Vertical offset is the distance from the shadow camera to the Fog Volume. To see the result, use the Prefab RT Viewer. You can see the 2 generated maps. First one is used for lightshafts, and second one is used to shade the scene:

Shadows rotate with sun direction, but the angle between the assigned light and the Volume can’t exceed 30º Beyond this angle, the shadows position won’t be correct.

Attach light==true will lock the light rotation to the volume rotation. It is useful to cast shadows from rotated volumes.

Shadow Color is the color of the scene shadows

The rest of the parameters controls the shadow blur.

Relative rotation between Volume and Sun can’t exceed 30º.

S H A D O W C A S T E R

62 of 105

LIGHTING

VOLUME

SHADOWS

Shadow projector

A new box will be created to shade your scene once you have activated Casts Shadows. You will find it as a child of your shadow caster volume:

Adjust its vertical position and vertical scale manually, until every object in your scene is inside of it.

A new object will be created to shade your scene

S H A D O W P R O J E C T O R

63 of 105

LIGHTING

VOLUMETRIC

SHADOWS

Shadow receiver

Go to the mesh renderer and set Receive Shadows ON

The shadow caster will then show some more options in the lighting tab:

Fill the slot with your shadow caster.

Shadow Cutoff is simply a contrast adjust.

At the very bottom of the inspector you will find DrawOrder. Clouds must be drawn first.

Shade a volume with another one

S H A D O W R E C E I V E R

64 of 105

LIGHTING

SCENE

SHADOWS

Directional light

To enable scene volumetric shadows we add the script

“FogVolumeDirectionalLight” to our main light:

Only textured volumes can sample shadows. Gradient or noise must be enabled.

65 of 105

Directional light: setup

After adding the script, we are prompted to fill some slots.

  1. Target Fog Volume
  2. Layer used to cast shadows

https://youtu.be/OdvzG7oNR80?t=3m32s

NOTE

Shadows only affect direct light components:

  • In-scattering
  • Directional lighting

66 of 105

Directional light: view range

By default, the shadow camera will use the assigned volume size (X axis) to determine the view range. The whole volume will be visible and we will get volumetric shadows for the whole volume.

67 of 105

Directional light: focus position

By default It will focus on the center of the assigned volume. But we can change that switching to Scale mode: Manual and Focus point: Game camera position or GameObject. This way we can render the shadowmap only for a specific location when we have a large volume.

Example:

We want to bake a static shadow for these towers:

68 of 105

Directional light: baked shadow

With Update mode set to Interleaved (dynamic) we tweak Zoom and our game camera position until we have a good view of the area of interest where we want to bake the shadow. Once we are happy with the location and view range we can switch to Update Mode: On Start.

We can now fly anywhere and the shadows will stay in the correct position. The cost of sampling this shadow depends on its size and FV iterations.

69 of 105

Directional light: shadowmap edges transition

If not taken into account, the edges of the shadowmap will cause shadows to appear suddenly. We will adjust the borders fade using “Edge Softness”.

Notice the smooth black frame in the miniature:

Smoothing range

70 of 105

Halo is an optical phenomena easily visible in cloudy nights around the moonlight. Light gets refracted as it travels throughout the cloud.

71 of 105

LIGHTING

Halo

You will find Halo in the lighting tab. It starts with a texture like this:

Width and Radius will define the main shape of the ring.

Absorption will simulate how much light is scattered in the cloud, becoming more blurry according to opacity.

Radial rainbows around moon/sunlight.

It contains a 1D Grayscale gradient, which is used to generate the colorful dispersion.

Left side corresponds to the center point of the lightsource. Right side is where the halo phenomena is more evident. We paint there sharper gradients.

To do: sliders to customize the RGB offsets

H A L O

72 of 105

73 of 105

LIGHTING

METHODS

Lights

For existing lights, add the script FogVolumeLight.cs and Fog Volume will automatically recognize it. To create new lights, use the Fog Volume menu

We can create lights that are not Unity lights, but simulated lights that only works in fog volume and don’t cast shadows:

  • Fog Volume Point Light
  • Fog Volume Spot Light

Turn Real-time search ON to refresh or hit play once. Lights found inside the volume will be added. Turn Inside box only off to also add lights that are outside of the volume.

Once it is refreshed, turn off real-time search.

You have 3 attenuation methods to choose:

  • Beer’s Law (mainly for dense media)
  • Inverse square (air)
  • Linear (constant attenuation by distance)

Range Clamp helps to save gpu power, especially with Inverse square attenuation, which extends over long distances.

Draw Distance is used to discard the lights according to its distance from the camera.

LIMITATION

Because of the big amount of registers required, Pointlights have been disabled from 3.1.4 for machines with shader level below 4

L I G H T S

74 of 105

Lights discarding

Lights outside of the view frustum will be discarded from rendering. Light range is represented with a box and this is used to discard lights. When this box is not visible by the camera, this light is discarded from the render. Usually, when we use the attenuation method: inverse square, which is extended along large distances, we have to increase the size of this box so that the light is not discarded before it becomes not visible.

To view this box, enable other/ debug options / draw debug gizmos

Result:

Use Light visibility to increase the size of this box. This value multiplies the light range

75 of 105

LIGHTING

METHODS

Self - shadowing

We can get more realistic shading if we activate Self shadow.

In common cases, a small Shadow Distance and one Iteration will be enough. The image next shows an extreme situation, where upper clouds shade lower clouds.

S E L F - S H A D O W I N G

76 of 105

LIGHTING

METHODS

Directional

Directional lighting models the behaviour of light when it travels inside the cloud. The amount of absorbed light is defined by Density and the color inside the cloud is given by Extinction Color. Quality of this feature is adjusted with Iterations. Adjust Distance to determinate the distance between each iteration.

D I R E C T I O N A L

77 of 105

LIGHTING

METHODS

Lambertian

Normals are computed to calculate diffuse lighting. This method is extremely expensive, but we can compute it only at a given Distance from the camera.

Amount is the intensity of the effect.

Lambertian Bias goes from 0 to 1. If set to 0, the effect will darken all the lighting contributions. If set to 1, it brightens the lighting contributions.

Normal detail will define how much detail to preserve from the original cloud noise.

L A M B E R T I A N

78 of 105

LIGHTING

METHODS

Proxy Volume

As of 3.2 we can use proxy volumes to illuminate a textured fog. All we need is a light probe grid

P R O X Y V O L U M E

79 of 105

Proxy Volume

In some cases we will want to tint our (textured) Fog Color with the ambient, specially when using these GI probes

80 of 105

Proxy Volume: performance

Sampling the probe grid is a complex operation and performance suffers quite a lot:

81 of 105

Fog Volume allows to use box meshes to model / mask noise.

82 of 105

PRIMITIVES

We can create a primitive via menu button

Or using the “Create” button in the Hierarchy tab

83 of 105

PRIMITIVES

We can feed Fog Volume with cube or spheres meshes to shape noise.

Enable Primitives to activate this option. Turn Real-time search on to find the primitives that are in the scene. Once they are detected, turn it off.

Distance fields only affect noise and gradients.

Bug: when not in play mode Enable primitives and Show primitives checkers are not updating the viewport until you click on it.

With Size==0, Softness==1 and Cutout==1 we get a sharp cube, faithful to the original

84 of 105

PRIMITIVES

In the case of the scene “Pillars” we want to get an artistic look, we don’t want sharp boxes but soft shapes. With Size we override the box mesh scale. With Softness we make box edges softer. Cutout is used to trim ignoring the soft shape we defined above.

-Noise nor Gradients are not computed outside the distance field.

-Each primitive you add increases cost

Turn off Real-time search once the list is filled with your primitives.

�Turn it on only to update the list.

85 of 105

PRIMITIVES

Let’s see another case where primitives would be useful. Imagine the following situation

We want Fog only inside of the building and not outside. We create a Volume that wraps the building and then we add 3 FV primitives and adjust their sizes and positions to match the room and corridor volume

These are the values to match the distance field with our building mesh.

86 of 105

PRIMITIVES

To enable the subtractive mode, choose between “Action types”

Only 20 primitives are rendered at once. The system will render the 20 closest ones and discard the rest according to the camera proximity when persistence type == Cullable. To avoid a primitive to be discarded, set the “Persistence type” to Persistent.

87 of 105

PRIMITIVES

BOX

We have now 3 different spaces resolved with a single Fog Volume

We can look through the window to the wall in front without having fog in the exterior.

88 of 105

Management

In the Color tab we have some post-processing such as photographic Tonemapper. Exposure will appear once activated.

Offset and Gamma are equivalent to the adjustment layer in Photoshop called Exposure (similar to brightness and contrast)

COLOR

89 of 105

Fog Volume provides different debug views to show us useful info.

90 of 105

DEBUG VIEW

MODES

Iterations

We find a drop-down list at the very bottom of the Renderer tab containing all the debug view modes currently available:

Raymarch stops when an opaque pixel is drawn.

Iterations shows us the amount of iterations performed per pixel.

Black means few iterations. Notice the black clouds. That means that an opaque pixel has been reached and therefore, the raymarch stops there. White means that the total iterations performed are getting close to Max Iterations.

I T E R A T I O N S

91 of 105

DEBUG VIEW

MODES

In-Scattering

We can also isolate the effect of incident light scattering

Isolate and rule!

I N - S C A T T E R I N G

92 of 105

DEBUG VIEW

MODES

Volume Fog In-Scattering clamp

This will show the depth we set in the Volume Fog In-scattering panel, in the lighting tab.

Not to be confused with In-scattering. This is the In-scattering component added to the Fog that fills the empty space left by the noise cloud (Volume Fog)

Start Distance is set to 0 by default, in that case what we get is a linear depth [0, 1].

I N - S C A T T E R I N G C L A M P

93 of 105

DEBUG VIEW

MODES

Volume Fog Phase (In-Scattering)

With this view mode we can isolate the final Volume Fog In-scattering

V O L U M E F O G I N - S C A T T E R I N G

94 of 105

95 of 105

SCREEN

EFFECT

96 of 105

97 of 105

Screen FX

Since 3.1.8 we have a new module for image effects.

It will convolve the output image based on Fog Volumes Density.

Add FogVolumeScreen.cs to the camera and select the Fog Volume layer you want to use as density input.

Use the prefab RT_Viewer to see the density input:

RECOMMENDATION

Don’t ever use FogVolume layer as density input, use FogVolumeSurrogate and it will be free!!

98 of 105

IMPORTANT:

The assigned light must have these layers disabled:

Fog Volume will do this automatically anyway. In case that the RT_Viewer does not show scene depth, this is the first thing to check.

99 of 105

POSSIBLE ISSUES:

_CameraDepthTexture is required to make this work, but in some configurations it is not generated. With a deferred camera it will always work, but lets see some cases with forward camera

  • Using Postprocess-stack: it disables depth generation unless we turn on DOF, Motion blur, AO or TAA
  • Not using PP stack?: you can use EnableDepthInForwardCamera.cs

No _CameraDepthTexture available

100 of 105

Screen FX: parameters

  • Density Layer: layer used as density input. This will be used as blur intensity
  • Falloff: allows us to override the input density and make the blur stronger at lower distances
  • Iterations: each iteration will sample the screen 4 times in full resolution. Be carefull with this :) 2 iterations will be enough
  • Dither: this adds some noise to the sample coordinates. Use Playdead temporal reprojection to smooth the result
  • Blur Spread: multiplies the fog density input (blur amount)

Module A: Scene Blur

  • Bloom Dowsample: initial scale of the input sampler
  • Threshold: luminance minimum value
  • Intensity: effect intensity
  • Saturation: color saturation of the blurred image
  • Blur Size: bloom effect overall size
  • Blur iterations: how many times to iterate the blur
  • Scene Bloom==On: Fog Volume + Scene is used in the effect
  • Scene Bloom==Off: Only Fog Volume is blurred

Module B: Bloom

101 of 105

Screen FX

Select the Surrogate layer to use a textured Fog Volume as density input

102 of 105

103 of 105

THE AUTHOR

DAVID

MIRANDA

Freelance Technical Artist

104 of 105

ACKNOWLEDGMENTS

RUBÉN

ALCAÑIZ

Indie game programmer

CHRISTOPHER

SCHIEFER

Concept & Technical Artist��

LEE

PERRY-SMITH

Director at Infinite-Realities

CARLOS

MACARRÓN

Rendering Engineer at DICE

ROD

LÓPEZ

Software fellow at Unity Technologies

FOR SUPPORT IN DIVERSE FORMATS

105 of 105

T H A N K S