Raymarching is the gateway to 3D shader graphics. For each pixel, you fire a ray from the camera into the scene. At every step, you ask the scene's SDF "how far is the nearest surface?" and advance by that distance — this is called sphere tracing. When the distance shrinks to nearly zero, the ray has hit something. You then compute the surface normal by sampling the SDF gradient, which gives you everything you need for lighting. This tutorial renders a 3D sphere on a checkerboard floor — entirely from math, no mesh data needed.
Key Concepts
ray origin / direction
sphere tracing loop
scene SDF
getNormal via gradient
diffuse lighting
Try this shader live in the Shader Sandbox editor with real-time preview.