Two-Color Blended Gradient
22 / 30
Achieve a left-to-right two-color gradient effect on the screen through linear interpolation, mastering the basics of blending and UV coordinates in GLSL.
This is the Module 1 capstone. You already know UV coordinates and mix — now combine them to drive a horizontal gradient with vUv.x.
Review: how mix works
t = 0.0→ fully colorAt = 1.0→ fully colorBt = vUv.x→ colorA on the left, colorB on the right
This exercise uses vUv
No need to compute UV manually here — the vertex shader passes in normalized coordinates:
Use vUv.x directly. No gl_FragCoord / u_resolution needed.
Exercise
The exercise code sets blendedColor directly to color1 (solid red). Change it to mix(color1, color2, vUv.x) so the canvas fades from red on the left to green on the right.
Answer Breakdown
vUv.x runs 0→1 left to right. mix interpolates between the two colors: fully color1 (red) on the left, fully color2 (green) on the right, blending in between.
Swap vUv.x for vUv.y to get a bottom-to-top gradient instead.