intermediate

#7 Smooth Functions

mix, smoothstep, clamp

Three built-in functions form the backbone of shader math. mix(a, b, t) blends smoothly between two values — perfect for color gradients and transitions. smoothstep(edge0, edge1, x) maps a value into a smooth S-curve between 0 and 1, giving you soft edges instead of harsh cutoffs. clamp(x, min, max) keeps a value within bounds. Mastering these three functions lets you shape and blend almost any visual effect.

Key Concepts

Try this shader live in the Shader Sandbox editor with real-time preview.
Open in Sandbox

Source Code


    
← Previous Patterns & Tiling Next → Noise

All Tutorials