Contrast with pow()

4 / 30
Apply pow() to reshape a gradient curve.

The gradient factor t is linear by default. pow(t, n) bends the curve, making the gradient feel faster or slower.


How pow changes the curve

pow(t, n) raises a 0–1 value to a power:

  • n = 1.0: unchanged, linear
  • n = 2.0: slow start, fast end (more darks)
  • n = 0.5: fast start, slow end (more lights)

vUv.x is linear 0→1. pow(vUv.x, 2.0) keeps more of the canvas dark and compresses the bright area toward the right.


Try changing it

Change the exponent to feel the curve shift:

nEffect
0.5Gradient skews brighter
1.0Linear (default)
2.0Gradient skews darker
4.0High contrast

Exercise

The exercise has t = 0.0 (solid black). Use pow(vUv.x, 2.0) to compute t and see how the curve differs from linear.

Answer Breakdown

pow(vUv.x, 2.0) = vUv.x * vUv.x, squashing the linear 0→1 into a curve. Visually, the gradient changes slowly at the start and rapidly near the right edge.

Swap 2.0 for 0.5 (same as sqrt(vUv.x)) — the curve inverts, changing fast at the start and slowly at the end.

GLSL Code Editor

Correct Code Preview

Current Code Preview