Hard 3DAnimated

Bouncing ball on a checker floor

A bouncing ball over an infinite checkerboard floor fading into a sky-colored fog.

The target picture for the shader challenge "Bouncing ball on a checker floor"
Recreate this picture. You pass at a 99% match, then try to write it in fewer characters than the par.

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 1160 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

Camera
ro = (0, 0.6, -4), rd = normalize(float3(p, 1.6))
Floor
plane at y = -1 → distance is p.y + 1.0; scene = min(sphere, plane)
Ball
radius 0.7, center y = -0.3 + 0.8 * abs(sin(time * 2.0))
March
100 steps, give up at t > 40
Ball color
float3(0.95, 0.35, 0.3)
Checker
abs(fmod(floor(pos.x) + floor(pos.z), 2.0)) → lerp(float3(0.9), float3(0.2,0.2,0.25)) (floor if pos.y < -0.99)
Light
normalize(float3(0.6, 0.8, -0.5)), brightness 0.25 + 0.75 * diffuse
Sky
lerp(float3(0.75,0.85,1.0), float3(0.25,0.45,0.85), uv.y)
Fog
lerp(col, sky, 1.0 - exp(-0.0015 * t * t))

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