beginner

#2 UV Coordinates

Map screen position to color

Every pixel has a position on screen, and UV coordinates normalize that position to a 0–1 range so your shader looks the same at any resolution. You compute them by dividing gl_FragCoord.xy (the pixel's raw position) by iResolution.xy (the screen size). Once you have UVs, you can use them as colors to produce the classic red-green gradient — a visual proof that your coordinate system is working correctly.

Key Concepts

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

Source Code


    
← Previous Hello World Next → Animation

All Tutorials