Height Gradient
Height Gradient samples the world-space Y position of each pixel and blends colors (or layer weights) along that axis. It is the cheapest way to get snow on mountain tops, moss along waterlines, or lava that brightens at the base of a cliff, all from one texture-free function.
When to use it
- Snow caps on terrain and rocks.
- Waterlines — moss or dirt at the base of a wall.
- Lava cliffs — hot at the bottom, cool at the top.
- Atmospheric tinting for tall environments such as skyscrapers and towers.
Difference from Depth Coloring
How it works
The shader reads positionWS.y, subtracts _HeightMin, divides by _HeightMax - _HeightMin, and saturates the result. That 0–1 value becomes either the lerp factor for _BottomColor / _TopColor or the weight for a Layer Textures slot.
Properties
Usage
- Set Height Min / Max in world units. A 5m band gives a soft transition; 0.5m is a sharp ring.
- Pick the Bottom and Top colors. For snow, run warm rock to white-blue.
- Add a noise texture for organic edges — without it the band looks suspiciously straight.
- Switch Output to LayerWeight to drive Layer Textures instead of color.
material.SetFloat("_HeightMin", 4f);
material.SetFloat("_HeightMax", 12f);
material.SetColor("_TopColor", new Color(0.92f, 0.95f, 1.0f));Tips & gotchas
- The gradient is world-space, not local. Moving the mesh up keeps the snow at the same world height — usually correct for terrain, but watch moving props.
- Add noise: a straight horizontal band reads as fake instantly, and even 10% noise looks natural.
- Combine with Triplanar for terrain; both are world-space and pair perfectly.
- Lightmapped objects still receive the gradient on top of the bake — good for snow but odd for emissive lava, where the Emission output is better.
Related
- Layer Textures — height drives layer weights.
- Triplanar Mapping — world-space twin.
- Depth Coloring — camera-depth gradient for water.
- Emission — combine with height output for hot-glow lava.
Last updated on