Hard Coding adventures
Ray tracing: spheres, shadows and a mirror bounce
A tiny ray tracer: two spheres on a checkered floor. Shoot a ray per pixel, find the nearest hit, light it, check for a shadow, and bounce once to show reflections.
About the Ray tracing: spheres, shadows and a mirror bounce shader
A tiny ray tracer: two spheres on a checkered floor. Shoot a ray per pixel, find the nearest hit, light it, check for a shadow, and bounce once to show reflections. Experiments in the spirit of well-known open-source graphics projects: a software rasterizer, a ray tracer, procedural planets, fluid particles and more, rebuilt as pixel shaders.
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 2115 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.
What it is built from
- Scene
uses at, hitScene, normalAt, albedoAt, skyAt- Camera
uses normalize · colours float3(0.0, 0.2, 0.0)- Hit
uses hitScene, object, skyAt- Light
uses normalize, max, dot, hitScene- Mirror
uses reflect, hitScene, skyAt, max, dot, point- Mix
uses lerp
Only the building blocks and the colours are listed. Work out how they fit together, then measure the numbers from the target.
How to make a ray tracing: spheres, shadows and a mirror bounce shader
- pos = ro + rd * h.x is where the ray hits; the normal and albedo come from the helpers with h.y.
- Offset the start of the shadow and reflection rays by n * 0.003 or the surface shadows itself.
- The mirror bounce is the same code as the primary ray with new ro and rd: reflect(rd, n).
Techniques used
- Reflection: mirror a direction around a surface normal.
- Diffuse lighting: brightness from the angle between the surface and the light.
- lerp (mix): blend between two colors or values.
Ray tracing: spheres, shadows and a mirror bounce shader code, explained step by step
Try to build it yourself first, because that is how it sticks. When you want to check your work or you are stuck, this is a complete working solution cut into parts, with the idea behind each part. The parts are in HLSL (Unity and Unreal); the full code below comes in every language.
Part 1: Helper: hitSphere()
float hitSphere(float3 ro, float3 rd, float3 c, float r)
{
float3 oc = ro - c;
float b = dot(oc, rd);
float h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) return -1.0;
float t = -b - sqrt(h);
if (t < 0.001) return -1.0;
return t;
} - The ray-sphere test: solving a quadratic tells whether, and at what distance, a ray hits a sphere.
Part 2: Helper: hitScene()
float2 hitScene(float3 ro, float3 rd)
{
float t = 100000.0;
float id = 0.0;
float t1 = hitSphere(ro, rd, float3(-0.6, 0.0, 3.2), 0.6);
float t2 = hitSphere(ro, rd, float3(0.7, -0.15, 3.8), 0.45);
float t3 = (rd.y < -0.001) ? (-0.6 - ro.y) / rd.y : -1.0;
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return float2(t, id);
} - A helper function the main shader calls. It is handed out in the challenge Toolbox, so you can paste it in with one click.
Part 3: Helper: normalAt()
float3 normalAt(float id, float3 pos)
{
if (id < 1.5) return normalize(pos - float3(-0.6, 0.0, 3.2));
if (id < 2.5) return normalize(pos - float3(0.7, -0.15, 3.8));
return float3(0.0, 1.0, 0.0);
} - A helper function the main shader calls. It is handed out in the challenge Toolbox, so you can paste it in with one click.
Part 4: Helper: albedoAt()
float3 albedoAt(float id, float3 pos)
{
if (id < 1.5) return float3(0.9, 0.25, 0.25);
if (id < 2.5) return float3(0.25, 0.5, 0.9);
float c = step(0.5, frac((floor(pos.x) + floor(pos.z)) * 0.5));
return lerp(float3(0.25, 0.25, 0.28), float3(0.75, 0.75, 0.78), c);
} - A helper function the main shader calls. It is handed out in the challenge Toolbox, so you can paste it in with one click.
Part 5: Helper: skyAt()
float3 skyAt(float3 rd)
{
return lerp(float3(0.75, 0.85, 0.95), float3(0.3, 0.5, 0.85), saturate(rd.y * 1.2 + 0.2));
} - The sky: a gradient from the horizon colour to the zenith colour, usually plus a glow around the sun.
Part 6: Set up the coordinates
Inside float4 frag(float2 uv)
float2 p = (uv - 0.5) * float2(aspect, 1.0) * 2.0;
float3 ro = float3(0.0, 0.2, 0.0);
float3 rd = normalize(float3(p.x, p.y - 0.1, 1.5)); - Centre the coordinates on the middle of the picture and multiply x by the aspect ratio, so a circle stays round on a wide picture.
- Subtracting 0.5 moves the origin from the bottom-left corner to the middle of the picture.
- normalize() scales a direction to length 1, so only its direction matters.
- float3(r, g, b) is a colour: each channel from 0 (none) to 1 (full).
Part 7: Choose the colours
Still inside frag()
float3 sun = normalize(float3(-0.5, 0.8, -0.4));
float2 h = hitScene(ro, rd);
float3 col = skyAt(rd); - normalize() scales a direction to length 1, so only its direction matters.
- float3(r, g, b) is a colour: each channel from 0 (none) to 1 (full).
- A ray test: it returns how far along the ray the nearest surface (or the entry and exit of a volume) is.
Part 8: Choose the colours (continued)
Still inside frag()
if (h.y > 0.5)
{
float3 pos = ro + rd * h.x;
float3 n = normalAt(h.y, pos);
float3 alb = albedoAt(h.y, pos);
float diff = max(dot(n, sun), 0.0);
float shadow = (hitScene(pos + n * 0.003, sun).y > 0.5) ? 0.3 : 1.0;
float3 own = alb * (0.15 + 0.85 * diff * shadow);
float3 rr = reflect(rd, n);
float2 h2 = hitScene(pos + n * 0.003, rr);
float3 refl = skyAt(rr);
if (h2.y > 0.5)
{
float3 pos2 = pos + n * 0.003 + rr * h2.x;
float3 n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
float k = (h.y < 2.5) ? 0.35 : 0.15;
col = lerp(own, refl, k);
} - The code inside the braces only runs when the condition is true.
- lerp(a, b, t) blends from a to b. With a mask as t it paints one colour over another.
- The dot product of the surface normal and the light direction is the diffuse light: bright where the surface faces the light, dark where it faces away.
- reflect() mirrors a direction around a surface normal: where a ray goes after bouncing.
Part 9: Colour the pixel and return it
Still inside frag()
return float4(col, 1.0); - The shader returns the final colour: red, green, blue, and an alpha of 1 (fully opaque).
The full code
HLSL Unity, Unreal
float hitSphere(float3 ro, float3 rd, float3 c, float r)
{
float3 oc = ro - c;
float b = dot(oc, rd);
float h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) return -1.0;
float t = -b - sqrt(h);
if (t < 0.001) return -1.0;
return t;
}
float2 hitScene(float3 ro, float3 rd)
{
float t = 100000.0;
float id = 0.0;
float t1 = hitSphere(ro, rd, float3(-0.6, 0.0, 3.2), 0.6);
float t2 = hitSphere(ro, rd, float3(0.7, -0.15, 3.8), 0.45);
float t3 = (rd.y < -0.001) ? (-0.6 - ro.y) / rd.y : -1.0;
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return float2(t, id);
}
float3 normalAt(float id, float3 pos)
{
if (id < 1.5) return normalize(pos - float3(-0.6, 0.0, 3.2));
if (id < 2.5) return normalize(pos - float3(0.7, -0.15, 3.8));
return float3(0.0, 1.0, 0.0);
}
float3 albedoAt(float id, float3 pos)
{
if (id < 1.5) return float3(0.9, 0.25, 0.25);
if (id < 2.5) return float3(0.25, 0.5, 0.9);
float c = step(0.5, frac((floor(pos.x) + floor(pos.z)) * 0.5));
return lerp(float3(0.25, 0.25, 0.28), float3(0.75, 0.75, 0.78), c);
}
float3 skyAt(float3 rd)
{
return lerp(float3(0.75, 0.85, 0.95), float3(0.3, 0.5, 0.85), saturate(rd.y * 1.2 + 0.2));
}
float4 frag(float2 uv)
{
float2 p = (uv - 0.5) * float2(aspect, 1.0) * 2.0;
float3 ro = float3(0.0, 0.2, 0.0);
float3 rd = normalize(float3(p.x, p.y - 0.1, 1.5));
float3 sun = normalize(float3(-0.5, 0.8, -0.4));
float2 h = hitScene(ro, rd);
float3 col = skyAt(rd);
if (h.y > 0.5)
{
float3 pos = ro + rd * h.x;
float3 n = normalAt(h.y, pos);
float3 alb = albedoAt(h.y, pos);
float diff = max(dot(n, sun), 0.0);
float shadow = (hitScene(pos + n * 0.003, sun).y > 0.5) ? 0.3 : 1.0;
float3 own = alb * (0.15 + 0.85 * diff * shadow);
float3 rr = reflect(rd, n);
float2 h2 = hitScene(pos + n * 0.003, rr);
float3 refl = skyAt(rr);
if (h2.y > 0.5)
{
float3 pos2 = pos + n * 0.003 + rr * h2.x;
float3 n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
float k = (h.y < 2.5) ? 0.35 : 0.15;
col = lerp(own, refl, k);
}
return float4(col, 1.0);
} GLSL Shadertoy, three.js, OpenGL
float hitSphere(vec3 ro, vec3 rd, vec3 c, float r)
{
vec3 oc = ro - c;
float b = dot(oc, rd);
float h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) return -1.0;
float t = -b - sqrt(h);
if (t < 0.001) return -1.0;
return t;
}
vec2 hitScene(vec3 ro, vec3 rd)
{
float t = 100000.0;
float id = 0.0;
float t1 = hitSphere(ro, rd, vec3(-0.6, 0.0, 3.2), 0.6);
float t2 = hitSphere(ro, rd, vec3(0.7, -0.15, 3.8), 0.45);
float t3 = (rd.y < -0.001) ? (-0.6 - ro.y) / rd.y : -1.0;
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return vec2(t, id);
}
vec3 normalAt(float id, vec3 pos)
{
if (id < 1.5) return normalize(pos - vec3(-0.6, 0.0, 3.2));
if (id < 2.5) return normalize(pos - vec3(0.7, -0.15, 3.8));
return vec3(0.0, 1.0, 0.0);
}
vec3 albedoAt(float id, vec3 pos)
{
if (id < 1.5) return vec3(0.9, 0.25, 0.25);
if (id < 2.5) return vec3(0.25, 0.5, 0.9);
float c = step(0.5, fract((floor(pos.x) + floor(pos.z)) * 0.5));
return mix(vec3(0.25, 0.25, 0.28), vec3(0.75, 0.75, 0.78), c);
}
vec3 skyAt(vec3 rd)
{
return mix(vec3(0.75, 0.85, 0.95), vec3(0.3, 0.5, 0.85), clamp(rd.y * 1.2 + 0.2, 0.0, 1.0));
}
vec4 frag(vec2 uv)
{
vec2 p = (uv - 0.5) * vec2(aspect, 1.0) * 2.0;
vec3 ro = vec3(0.0, 0.2, 0.0);
vec3 rd = normalize(vec3(p.x, p.y - 0.1, 1.5));
vec3 sun = normalize(vec3(-0.5, 0.8, -0.4));
vec2 h = hitScene(ro, rd);
vec3 col = skyAt(rd);
if (h.y > 0.5)
{
vec3 pos = ro + rd * h.x;
vec3 n = normalAt(h.y, pos);
vec3 alb = albedoAt(h.y, pos);
float diff = max(dot(n, sun), 0.0);
float shadow = (hitScene(pos + n * 0.003, sun).y > 0.5) ? 0.3 : 1.0;
vec3 own = alb * (0.15 + 0.85 * diff * shadow);
vec3 rr = reflect(rd, n);
vec2 h2 = hitScene(pos + n * 0.003, rr);
vec3 refl = skyAt(rr);
if (h2.y > 0.5)
{
vec3 pos2 = pos + n * 0.003 + rr * h2.x;
vec3 n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
float k = (h.y < 2.5) ? 0.35 : 0.15;
col = mix(own, refl, k);
}
return vec4(col, 1.0);
} WGSL WebGPU, Bevy
fn hitSphere(ro: vec3f, rd: vec3f, c: vec3f, r: f32) -> f32
{
let oc = ro - c;
let b = dot(oc, rd);
let h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) { return -1.0; }
let t = -b - sqrt(h);
if (t < 0.001) { return -1.0; }
return t;
}
fn hitScene(ro: vec3f, rd: vec3f) -> vec2f
{
var t = 100000.0;
var id = 0.0;
let t1 = hitSphere(ro, rd, vec3f(-0.6, 0.0, 3.2), 0.6);
let t2 = hitSphere(ro, rd, vec3f(0.7, -0.15, 3.8), 0.45);
let t3 = select(-1.0, (-0.6 - ro.y) / rd.y, (rd.y < -0.001));
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return vec2f(t, id);
}
fn normalAt(id: f32, pos: vec3f) -> vec3f
{
if (id < 1.5) { return normalize(pos - vec3f(-0.6, 0.0, 3.2)); }
if (id < 2.5) { return normalize(pos - vec3f(0.7, -0.15, 3.8)); }
return vec3f(0.0, 1.0, 0.0);
}
fn albedoAt(id: f32, pos: vec3f) -> vec3f
{
if (id < 1.5) { return vec3f(0.9, 0.25, 0.25); }
if (id < 2.5) { return vec3f(0.25, 0.5, 0.9); }
let c = step(0.5, fract((floor(pos.x) + floor(pos.z)) * 0.5));
return mix(vec3f(0.25, 0.25, 0.28), vec3f(0.75, 0.75, 0.78), c);
}
fn skyAt(rd: vec3f) -> vec3f
{
return mix(vec3f(0.75, 0.85, 0.95), vec3f(0.3, 0.5, 0.85), saturate(rd.y * 1.2 + 0.2));
}
fn frag(uv: vec2f) -> vec4f
{
let p = (uv - 0.5) * vec2f(aspect, 1.0) * 2.0;
let ro = vec3f(0.0, 0.2, 0.0);
let rd = normalize(vec3f(p.x, p.y - 0.1, 1.5));
let sun = normalize(vec3f(-0.5, 0.8, -0.4));
let h = hitScene(ro, rd);
var col = skyAt(rd);
if (h.y > 0.5)
{
let pos = ro + rd * h.x;
let n = normalAt(h.y, pos);
let alb = albedoAt(h.y, pos);
let diff = max(dot(n, sun), 0.0);
let shadow = select(1.0, 0.3, (hitScene(pos + n * 0.003, sun).y > 0.5));
let own = alb * (0.15 + 0.85 * diff * shadow);
let rr = reflect(rd, n);
let h2 = hitScene(pos + n * 0.003, rr);
var refl = skyAt(rr);
if (h2.y > 0.5)
{
let pos2 = pos + n * 0.003 + rr * h2.x;
let n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
let k = select(0.15, 0.35, (h.y < 2.5));
col = mix(own, refl, k);
}
return vec4f(col, 1.0);
} Godot Godot 4 shading language
shader_type canvas_item;
float hitSphere(vec3 ro, vec3 rd, vec3 c, float r)
{
vec3 oc = ro - c;
float b = dot(oc, rd);
float h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) return -1.0;
float t = -b - sqrt(h);
if (t < 0.001) return -1.0;
return t;
}
vec2 hitScene(vec3 ro, vec3 rd)
{
float t = 100000.0;
float id = 0.0;
float t1 = hitSphere(ro, rd, vec3(-0.6, 0.0, 3.2), 0.6);
float t2 = hitSphere(ro, rd, vec3(0.7, -0.15, 3.8), 0.45);
float t3 = (rd.y < -0.001) ? (-0.6 - ro.y) / rd.y : -1.0;
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return vec2(t, id);
}
vec3 normalAt(float id, vec3 pos)
{
if (id < 1.5) return normalize(pos - vec3(-0.6, 0.0, 3.2));
if (id < 2.5) return normalize(pos - vec3(0.7, -0.15, 3.8));
return vec3(0.0, 1.0, 0.0);
}
vec3 albedoAt(float id, vec3 pos)
{
if (id < 1.5) return vec3(0.9, 0.25, 0.25);
if (id < 2.5) return vec3(0.25, 0.5, 0.9);
float c = step(0.5, fract((floor(pos.x) + floor(pos.z)) * 0.5));
return mix(vec3(0.25, 0.25, 0.28), vec3(0.75, 0.75, 0.78), c);
}
vec3 skyAt(vec3 rd)
{
return mix(vec3(0.75, 0.85, 0.95), vec3(0.3, 0.5, 0.85), clamp(rd.y * 1.2 + 0.2, 0.0, 1.0));
}
vec4 frag(vec2 uv)
{
vec2 p = (uv - 0.5) * vec2(aspect, 1.0) * 2.0;
vec3 ro = vec3(0.0, 0.2, 0.0);
vec3 rd = normalize(vec3(p.x, p.y - 0.1, 1.5));
vec3 sun = normalize(vec3(-0.5, 0.8, -0.4));
vec2 h = hitScene(ro, rd);
vec3 col = skyAt(rd);
if (h.y > 0.5)
{
vec3 pos = ro + rd * h.x;
vec3 n = normalAt(h.y, pos);
vec3 alb = albedoAt(h.y, pos);
float diff = max(dot(n, sun), 0.0);
float shadow = (hitScene(pos + n * 0.003, sun).y > 0.5) ? 0.3 : 1.0;
vec3 own = alb * (0.15 + 0.85 * diff * shadow);
vec3 rr = reflect(rd, n);
vec2 h2 = hitScene(pos + n * 0.003, rr);
vec3 refl = skyAt(rr);
if (h2.y > 0.5)
{
vec3 pos2 = pos + n * 0.003 + rr * h2.x;
vec3 n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
float k = (h.y < 2.5) ? 0.35 : 0.15;
col = mix(own, refl, k);
}
return vec4(col, 1.0);
}
void fragment()
{
// Godot's UV starts at the top-left, the lessons use bottom-left
COLOR = frag(vec2(UV.x, 1.0 - UV.y));
} Metal iOS, macOS
float hitSphere(float3 ro, float3 rd, float3 c, float r)
{
float3 oc = ro - c;
float b = dot(oc, rd);
float h = b * b - (dot(oc, oc) - r * r);
if (h < 0.0) return -1.0;
float t = -b - sqrt(h);
if (t < 0.001) return -1.0;
return t;
}
float2 hitScene(float3 ro, float3 rd)
{
float t = 100000.0;
float id = 0.0;
float t1 = hitSphere(ro, rd, float3(-0.6, 0.0, 3.2), 0.6);
float t2 = hitSphere(ro, rd, float3(0.7, -0.15, 3.8), 0.45);
float t3 = (rd.y < -0.001) ? (-0.6 - ro.y) / rd.y : -1.0;
if (t1 > 0.0 && t1 < t) { t = t1; id = 1.0; }
if (t2 > 0.0 && t2 < t) { t = t2; id = 2.0; }
if (t3 > 0.001 && t3 < t) { t = t3; id = 3.0; }
return float2(t, id);
}
float3 normalAt(float id, float3 pos)
{
if (id < 1.5) return normalize(pos - float3(-0.6, 0.0, 3.2));
if (id < 2.5) return normalize(pos - float3(0.7, -0.15, 3.8));
return float3(0.0, 1.0, 0.0);
}
float3 albedoAt(float id, float3 pos)
{
if (id < 1.5) return float3(0.9, 0.25, 0.25);
if (id < 2.5) return float3(0.25, 0.5, 0.9);
float c = step(0.5, fract((floor(pos.x) + floor(pos.z)) * 0.5));
return mix(float3(0.25, 0.25, 0.28), float3(0.75, 0.75, 0.78), c);
}
float3 skyAt(float3 rd)
{
return mix(float3(0.75, 0.85, 0.95), float3(0.3, 0.5, 0.85), saturate(rd.y * 1.2 + 0.2));
}
float4 frag(float2 uv)
{
float2 p = (uv - 0.5) * float2(aspect, 1.0) * 2.0;
float3 ro = float3(0.0, 0.2, 0.0);
float3 rd = normalize(float3(p.x, p.y - 0.1, 1.5));
float3 sun = normalize(float3(-0.5, 0.8, -0.4));
float2 h = hitScene(ro, rd);
float3 col = skyAt(rd);
if (h.y > 0.5)
{
float3 pos = ro + rd * h.x;
float3 n = normalAt(h.y, pos);
float3 alb = albedoAt(h.y, pos);
float diff = max(dot(n, sun), 0.0);
float shadow = (hitScene(pos + n * 0.003, sun).y > 0.5) ? 0.3 : 1.0;
float3 own = alb * (0.15 + 0.85 * diff * shadow);
float3 rr = reflect(rd, n);
float2 h2 = hitScene(pos + n * 0.003, rr);
float3 refl = skyAt(rr);
if (h2.y > 0.5)
{
float3 pos2 = pos + n * 0.003 + rr * h2.x;
float3 n2 = normalAt(h2.y, pos2);
refl = albedoAt(h2.y, pos2) * (0.15 + 0.85 * max(dot(n2, sun), 0.0));
}
float k = (h.y < 2.5) ? 0.35 : 0.15;
col = mix(own, refl, k);
}
return float4(col, 1.0);
} Helper functions provided
The toolbox has: Scene helpers. 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 codingQuestions about this shader
How do I make a ray tracing: spheres, shadows and a mirror bounce shader?
A tiny ray tracer: two spheres on a checkered floor. A good first step: pos = ro + rd * h.x is where the ray hits; the normal and albedo come from the helpers with h.y. In ShaderBattle you build it in the browser with a live match bar, so you see how close you are after every change.
What techniques does the ray tracing: spheres, shadows and a mirror bounce shader use?
It is built from reflection, diffuse lighting, lerp (mix). Each one is a small idea you can reuse in other effects.
Does this ray tracing: spheres, shadows and a mirror bounce shader work in Unity, Unreal, Godot and Shadertoy?
Yes. The idea is the same in every shader language. ShaderBattle shows the code in HLSL (Unity, Unreal), GLSL (Shadertoy, three.js, OpenGL), WGSL (WebGPU), Metal and Godot, and exports a ready-to-paste version.