Start here · lesson 2 of 2 · Beginner · about 5 min
Colors are four numbers
You will build: Match the green. The Colors panel shows its hex code — convert it to floats.
A pixel's output is float4(r, g, b, a). Each channel runs from 0.0 to 1.0, not 0–255. So 0.5 is about 128. (Alpha is ignored on this page; in Unity it matters for transparent shaders.)
To convert from a hex color: take each byte and divide by 255.
| Hex byte | Decimal | ÷ 255 |
|---|---|---|
| FF | 255 | 1.0 |
| 80 | 128 | ≈ 0.5 |
| 00 | 0 | 0.0 |
Colors add light, like a monitor: red + green = yellow, all three at full = white, all zero = black.
Try it in your own language
The lesson is written once and shown in every language. Pick yours: Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.
Start codingGo deeper
Concept explainers with a live example: cosine palette.
Part of the learning paths: From zero to ray marching, From Shadertoy to Unity, Shader art basics.