Hard Raymarch
Ambient occlusion
Three spheres resting on a floor, with dark creases where surfaces get close: ambient occlusion.
How this challenge works
You write a fragment shader that draws the picture above, live in your browser. A match bar shows how close you are, and the score combines accuracy, code size (the par is 1268 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.
The numbers you need
- Scene
spheres at float3(-1.1, -0.4, 0.0) r 0.6, float3(0.0, -0.55, 0.0) r 0.45, float3(1.0, -0.3, 0.2) r 0.7; floor p.y + 1.0; map = min of all- Camera
ro = float3(0.0, 0.8, -4.5), rd = normalize(float3(p.x, p.y - 0.15, 1.6))- AO
ao = 0; for k in 1..5: h = 0.12 * k; ao += (h - map(pos + n * h)) / pow(2.0, k) (use float k); occ = 1.0 - saturate(ao * 3.0)- Light
normalize(float3(0.6, 0.8, -0.5)), brightness (0.1 + 0.9 * diffuse) * (0.4 + 0.6 * occ)- Colors
floor float3(0.75), spheres float3(0.9, 0.5, 0.35), background float3(0.55, 0.7, 0.9)
Helper functions provided
The toolbox has: calcNormal(). Add them above your frag function with one click.
Solve it in your language
Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.
Start coding