Shader guides
Short, practical explanations with code. Each one links to the interactive lessons where you can try it.
- What is a fragment shader? A plain explanation with codeA fragment (pixel) shader is a tiny function the GPU runs once for every pixel, all at the same time. See what it receives, what it returns, and write one yourself.
- HLSL vs GLSL vs WGSL vs Metal: shader languages comparedWhich shader language should you learn? Compare HLSL, GLSL, WGSL, Metal and the Godot shading language: where each runs, how the syntax differs, and how to move between them.
- How to learn shader programming: a step-by-step roadmapA practical order for learning shaders from zero: pixels and color, shapes, motion, repetition, noise, 3D ray marching and real effects. With the exact lessons for each step.
- What is ray marching? Distance fields explained simplyRay marching draws 3D scenes with no 3D models: for each pixel, step along a ray until a distance function says you are touching something. A simple explanation with code.
- Noise in shaders: value noise, fBm and what they are forShaders have no random() function. Learn how hash functions, value noise and fractal noise (fBm) work, and how they make clouds, terrain, marble and fire.
- How to make an ocean shader: waves, Fresnel and foamBuild a realistic ocean in a fragment shader: sum of sine waves, ray marching a height field, Fresnel reflection of the sky, sun glitter, foam and haze. Step by step.
- Why is my circle an oval? UV coordinates and aspect ratio in shadersYour first circle comes out stretched because UV runs from 0 to 1 on both axes, while the picture is wider than it is tall. See why it happens and the two lines that fix it.
- step, lerp and smoothstep: the three functions behind most shader effectsHard edges, blends and soft edges: three small functions that show up in nearly every shader. What each one does, how they combine, and the mistakes to avoid.
- Signed distance functions explained: drawing shapes with mathA signed distance function tells you how far a pixel is from a shape. Learn the circle and box formulas, how to combine shapes, how to smooth them and outline them, and why 3D ray marching depends on the same idea.
- Porting a Shadertoy shader to Unity (GLSL to HLSL): a conversion guideMost Shadertoy code is GLSL, and Unity uses HLSL. The two are close cousins. Here is a practical table of what to rename, the few differences that really break things, and a worked example.
- How to debug a shader when you cannot print anythingA shader has no console and no debugger, but you can still see inside it. Turn numbers into colors, test one piece at a time, and use a checklist for the bugs everybody hits.
- Why is my shader slow? A practical guide to shader performanceShaders run for every pixel, so small costs multiply fast. Learn what makes a fragment shader expensive, the cheap changes that help most, and how to measure instead of guessing.