-
Notifications
You must be signed in to change notification settings - Fork 413
Gradient Fog
This demo shows how Renderer Features can be used to apply custom post processing effects to a scene. Having a distance fog in video games is a typical way to improve realism as well as reduce draw distance. A regular single color fog is a good option for this but sometimes a more interesting ans stylised fog might be wanted. The gradient fog is similar to a normal fog except the color changes based on distance.
A Shadergraph shader is created to describe the fog. It contains a custom node that describes how three colors should blend based on a distance. This function is defined in Shaders/GradientFogFunction.hlsl
. The pipeline will write the opaque texture into the _MainTex
of the shader which is then to blend between the fog color and the original scene color. A Scene Depth
node is remapped based on distance settings and fed into the custom gradient function.
The renderer feature is responsible of injecting a blit-like pass into the render pipeline. The feature creates a material based on the previously mentioned shader and updates its values each GradientFog
render pass based on the settings of the feature in the renderer asset.
This renderer feature is rather specific compared to something like the Render Objects
renderer feature which is very generic. Using this approach makes the feature very easy to use as the settings in the renderer can be tayolored specifcally to the feature: