Hard 3DAnimated

Metaballs (smooth union)

Three blobs that merge like liquid. Raymarch them with a smooth minimum.

The target picture for the shader challenge "Metaballs (smooth union)"
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 1185 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

smin
h = max(k - abs(a-b), 0.0)/k; return min(a,b) - h*h*k*0.25;
k
0.8
Ball 1
center float3(sin(time)*0.9, cos(time*1.3)*0.4, 0), radius 0.55
Ball 2
center float3(-sin(time*0.8)*0.9, sin(time*1.1)*0.5, 0), radius 0.65
Ball 3
center at the origin, radius 0.45
Color
float3(0.35,0.85,0.65) * (0.15 + 0.85 * diffuse)
Rim light
pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.5 added to color
Camera / light
same as the Raymarching lesson

Helper functions provided

The toolbox has: calcNormal(), smin(). 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