SC Post Effects Documentation

SC Post Effects
Version: 2.3.9
Review

8.1.3.Fog #

Adds distance and height-based fog to the scene. Features several color modes:

Uniform color
Fog will be a single color

Gradient Texture
Samples a horizontal gradient texture from left (near) to right (far). Will expose a distance parameter to control the length of the gradient.

Skybox color
Fog will take on the color of the skybox, making it seamlessly blend in.

Height fog density can be controlled by supplying a grayscale texture.

The light scattering feature will perform another bloom pass inside of the fog. Though, this is not available in URP.

Transparent materials

The effect relies on the depth texture Unity renders, which provides a means to measure the distance from the camera to an object’s pixel on screen. Based on this distance, a certain amount of fog is applied.

As such, shaders that don’t support depth writing will not be affected by fog. This usually means:

  • Transparent materials (water/particles/etc).
  • Sprites.
  • UI elements
  • Unlit materials (Built-in RP only).
  • Details/grass rendered through the terrain system.
  • (Built-in RP) Custom shaders without a ShadowCaster pass.
  • (URP) Custom shaders without a DepthOnly pass.

On these materials, an amount of fog gets applied based on whatever is behind them. This isn’t always noticeable, but very much so if an object is in front of the skybox.

Solution

The only way around this is to incorporate the fog shading into custom a shader for the above purposes, and using that instead. This is how Unity’s standard fog works, which applies fog directly to an object, rather than through post-processing effect. This is also far more efficient!

  • For the Built-in RP, you can include the SC Post Effects\Runtime\Fog\Fog.hlsl shader library and use the ApplyTransparentFog function. You can find an example shader here.
  • For URP, it’s possible to add fog support when using Shader Graph. In the SC Post Effects\Runtime\Fog\ShaderGraph folder, you’ll find an example shader that illustrates how this can be achieved. An instructions txt file can also be found here!
    • On the fog render feature the “Skip Transparents” option must be enabled when incorporating this.

(An alternative is to modify Unity’s/URP’s shader libraries, and replace the function that applies fog. This won’t be covered in further detail. Experienced graphics programmers can reference the SC Post Effects\Runtime\Fog\Fog.hlsl file)

Yes No Suggest edit
Last updated on May 19, 2023
6 of 6 users found this section helpful
Suggest Edit