Skip to Content
DocumentationFeaturesDepth Coloring

Depth Coloring

Depth Coloring samples the scene depth behind a transparent surface and remaps it into a color gradient — the standard way to fake underwater absorption, atmospheric haze, and stylized volumetrics from a single quad or water mesh.

When to use it

  • Water surfaces — a shallow-to-deep tint without volumetric tracing.
  • Atmospheric haze — fade distant geometry behind a transparent shell.
  • Stylized fog volumes — color-graded fog cards.
  • Sci-fi membranes — surfaces that fade as objects pass through them.

How it works

For each pixel the shader samples the scene depth (the opaque geometry behind the surface), subtracts the surface’s own depth, normalizes by _DepthRange, and uses the result as a lerp factor between _ShallowColor and _DeepColor. An exponential falloff curve approximates Beer-Lambert absorption.

Properties

Inspector labelShader propertyTypeDefaultDescription
Shallow Color_ShallowColorColorRGBA(0.3, 0.7, 0.9, 0.4)Tint at zero depth; alpha drives the fade-in.
Deep Color_DeepColorColorRGBA(0.05, 0.10, 0.20, 1.0)Tint at maximum depth.
Depth Range_DepthRangeFloat (0–100)10.0World-space distance for the full gradient.
Falloff_DepthFalloffEnumExponentialLinear or Exponential gradient curve.
Depth Bias_DepthBiasFloat (-1–1)0.0Offsets the gradient start; negative starts earlier.
Intensity_DepthFogIntensityFloat (0–1)1.0Blend amount against the lit surface.

Usage

  1. Enable Depth Texture on your URP Asset.
  2. Switch the material to Transparent and set the queue to 3000 or higher.
  3. Pick a Shallow / Deep pair appropriate to your water or fog.
  4. Tune Depth Range in world units to match the typical depth of the volume.
material.SetColor("_ShallowColor", new Color(0.40f, 0.80f, 0.85f, 0.35f)); material.SetColor("_DeepColor", new Color(0.05f, 0.12f, 0.25f, 1.00f)); material.SetFloat("_DepthRange", 8f);

Tips & gotchas

  • The depth texture only contains opaque geometry, so two depth-colored surfaces cannot see each other.
  • MSAA depth sampling is unreliable on some Android GPUs; Genesis falls back to a resolve copy, which carries a slight cost.
  • Exponential (Beer-Lambert) reads more believably for water; Linear is fine for sci-fi membranes.
  • The depth texture is per-eye in URP 12+, so single-pass stereo needs no code change.
Last updated on