Invert Gradient
8 / 30
Invert a gradient using (1.0 - t).
A horizontal gradient goes from black (left) to white (right). To reverse it, one operation: 1.0 - t.
Flip with 1.0 -
- Left:
vUv.x = 0.0→t = 1.0(white) - Right:
vUv.x = 1.0→t = 0.0(black)
What was 0 becomes 1, what was 1 becomes 0 — the direction completely flips.
Exercise
The exercise starts with t = 0.0 (solid black). Change t to 1.0 - vUv.x so the gradient runs from white (left) to black (right).
Answer Breakdown
1.0 - x is the simplest inversion: input 0 gives 1, input 1 gives 0, and values in between mirror symmetrically.
This trick works on any 0–1 value. Apply 1.0 - to any mask to flip it: white becomes black, inside becomes outside, bright becomes dark.