SC Post Effects Documentation

SC Post Effects
Version: 2.2.0
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.

via Gfycat

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

via Gfycat

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.

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 a post-processing effect.

  • For the Built-in RP, this unfortunately won’t be possible due to the related shader code being entangled in an abstraction created for cross-pipeline support.
    • In the Fog.cs script file, you can change PostProcessEvent.BeforeStack to PostProcessEvent.AfterStack to have “depth-less” materials render on top of the fog.
  • 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 November 23, 2021
5 of 5 users found this section helpful
Suggest Edit