skip to Main Content

Fog is not visible in a build (but works in Unity Editor)

Make sure the URP asset used for the building platform has “Depth Texture” enabled. Note that Unity can use a different URP asset for specific devices. The URP assets can be found in Project Settings / Graphics and Project Settings / Quality (commonly one URP asset per quality level, so make sure all quality levels have the Depth Texture option enabled in its URP asset).

Shadow Cascade Bug

Universal Rendering Pipeline 7.1.8 has a bug with shadow cascade.

Solution: please make sure you use URP 7.2.0 or later.

Visible noise

Noise can become apparent under certain circumstances, like dark areas or when using very low sample count, high dithering/jittering or shadows.

Solution: To make noise less apparent, reduce jittering and dittering, or use the Blur option in the Volumetric Fog Manager.

Shadows Not Visible

Select the URP asset and make sure Shadow Distance is far enough and that “Transparent Receive Shadows” option is enabled.

Shader can take some time to compile

The first time the shader is compiled, it can take some time due to the amount of shader features. To speed up this process, you can edit the Volumetric Fog2DURP shader file and remove some “multi_compile” pragma lines or use Shader Control tool from the Asset Store to list and disable keywords related to features that you are not going to use:

#pragma multi_compile _ _MAIN_LIGHT_SHADOWS // directional light shadow

#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE // shadow cascades

#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS // additional light shadows

#pragma multi_compile _ VF2_DEPTH_PREPASS // depth prepass

#pragma multi_compile_local_fragment _ VF2_POINT_LIGHTS VF2_NATIVE_LIGHTS // fast point or native lights

#pragma multi_compile_local_fragment _ VF2_RECEIVE_SHADOWS // receives directional light shadow

#pragma multi_compile_local_fragment VF2_SHAPE_BOX VF2_SHAPE_SPHERE // fog shape (box or sphere)

#pragma multi_compile_local_fragment _ V2F_DETAIL_NOISE // use 3d noise

Fog appearance is different in build or some features like fog of war are now working in build

Volumetric fog shader variants may  be missing in your app if the scene containing volumetric fog is not present in the main build or if some features like fog of war are not active in Editor (for example, enabled by a script at runtime). This happens because some fog features are defined as a “shader feature” which means that shader code will be included in the build only if Unity can recognize the use of that keyword in the main build during the anlaysis of the scene in the compilation. This can also happen if you use addressables.

#pragma shader_feature_local_fragment VF2_DISTANCE   // used by starting distance option

#pragma shader_feature_local_fragment VF2_VOIDS      // fog void feature

#pragma shader_feature_local_fragment VF2_FOW        // fog of war

#pragma shader_feature_local_fragment VF2_SURFACE    // terrain fit option

#pragma shader_feature_local_fragment VF2_DEPTH_GRADIENT // depth-based gradient option

#pragma shader_feature_local_fragment VF2_HEIGHT_GRADIENT // height-based gradient option

#pragma shader_feature_local_fragment VF2_LIGHT_COOKIE  // directional light cookie option

If your game is using some of the above features, like distance fog or fog of war, one way to ensure the proper shader variant will be included is replacing any of the above pragmas by a constant define.
For example, if your game uses the voids feature, you can replace the VF2_VOIDS line above by:

#define VF2_VOIDS 1

Alternatively you can add a “dummy” fog volume somewhere in the scene which uses the required feature to make sure Unity detects it and doesn’t strip the required shader code in the build.

A third option to solve this issue implies replacing the “shader_feature_local_fragment” with “multi_compile_local_fragment” for example, in the case of fog of war replacing the line above with:

#pragma multi_compile_local_fragment _ VF2_FOW // fog of war

will solve this issue (notice the required underscore “_” before the keyword).

Inverted Depth Bug

Universal Rendering Pipeline 7.2.0 has a bug which produces an incorrect (flipped) depth texture. This bug occurs when HDR is OFF, MSAA is x1 and Render Scale =1. More details here: https://forum.unity.com/threads/inverted-depth-texture-and-unresolved-shadowmap.824703/#post-5466879

Solution:

Option 1) Enabling HDR, MSAA or changing Render Scale (any of the three) produces the correct depth texture.

Option 2) Enable “Flip Depth Texture” option in Volumetric Fog Manager.

Shadows not showing in WebGL 2.0

Enable the option “Force WebGL Compatibility” in Volumetric Fog Manager.

You can also edit RayMarch2D.cginc file in Resources/Shaders folder and activate the following line:

// UNITY_UNROLLX(50)

(Increase the 50 value if needed)

Fog not rendering correctly when using VR in URP

URP 7.4 has a known bug related to inverted matrices not being set correctly in VR.

You can enable the option “Alternate WS Reconstruction” in Volumetric Fog Manager.

While this bug is not fixed by Unity, the workaround requires editing the file CommonsURP.hlsl and uncomment the line below:

//#define USE_ALTERNATE_RECONSTRUCT_API

Additional noise textures

You can find additional noise and detail noise textures inside the Demo / Noise Textures folder.

I have a question which is not covered in the guide

Please use the Support Forum and post your question there. Our team will get back to you shortly.

Back To Top