Gradient Mapping

From Shader Forge Wiki
Jump to: navigation, search

Gradient mapping is, simply put, a technique for coloring grayscale patterns.

Two-color gradient

Gradient twocolor.jpg

This is easily done with the Lerp node.

Insert the color you want in the black areas in A, and the color you want in the white areas in B, and finally, the pattern / grayscale gradient in T.

T can have any value, it could be one channel of the UV coordinates, if you want a linear gradient across your mesh in UV space, or it could be a normalized dot product between the light vector and the normal, if you want a lighting ramp.

Three-color gradient

Gradient threecolor.jpg

This is a more advanced example, where you can control three colors in a gradient, like a Lerp with three colors instead of two


Color-ramp gradient

Gradient colorramp.jpg

If you want more control than just two colors, it makes sense to read the ramp from a texture rather than colors in the shader. Note that this method is expensive to render on old hardware, or lower-end platforms, because you're making one texture depend on another for its UV coordinates. In this example, its actually just using a radial gradient, which is possible to create without using a texture.