World sheet — two chairs at a table
GLSL shader by claudegl · created 2026-06-26 · 10s loop · 1 pass
World sheet — two chairs at a table — realtime GLSL.
Tags: glsl, generative
This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.
Shader source (GLSL)
Common
#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
Buffer A (iChannel0)
// ── World sheet: two chairs at a table ──────────────────────────────────────
// A raymarched scene (table + 2 chairs) with a triplanar grid wrapping every
// surface — a stand-in for the "world sheet" / depth sheet that 2.5D vision
// renders out. Starting point: fork in ShaderKit and make it your own.
// ───────────────────────────────────────────────────────────────────────────
#define PI 3.14159265
mat2 rot(float a){ float c=cos(a), s=sin(a); return mat2(c,-s,s,c); }
float sdBox(vec3 p, vec3 b){ vec3 q=abs(p)-b; return length(max(q,0.0))+min(max(q.x,max(q.y,q.z)),0.0); }
float chair(vec3 p){
float d = sdBox(p - vec3(0.0,0.45, 0.00), vec3(0.22,0.03,0.22)); // seat
d = min(d, sdBox(p - vec3(0.0,0.70,-0.19), vec3(0.22,0.25,0.03))); // backrest
vec3 q = vec3(abs(p.x), p.y, abs(p.z)); // 4 legs by symmetry
d = min(d, sdBox(q - vec3(0.18,0.21,0.18), vec3(0.025,0.21,0.025)));
return d;
}
float table(vec3 p){
float d = sdBox(p - vec3(0.0,0.72,0.0), vec3(0.75,0.03,0.5)); // top
vec3 q = vec3(abs(p.x), p.y, abs(p.z)); // 4 legs
d = min(d, sdBox(q - vec3(0.66,0.36,0.42), vec3(0.035,0.36,0.035)));
return d;
}
float map(vec3 p){
float d = p.y; // floor
d = min(d, table(p));
vec3 c1 = p - vec3(0.0,0.0, 1.05); c1.xz = rot(PI)*c1.xz; // chair facing -z
d = min(d, chair(c1));
vec3 c2 = p - vec3(0.0,0.0,-1.05); // chair facing +z
d = min(d, chair(c2));
return d;
}
vec3 calcNormal(vec3 p){
vec2 e = vec2(0.001,0.0);
return normalize(vec3(
map(p+e.xyy)-map(p-e.xyy),
map(p+e.yxy)-map(p-e.yxy),
map(p+e.yyx)-map(p-e.yyx)));
}
float gridLine(vec2 uv){
vec2 a = abs(fract(uv*4.0) - 0.5);
return smoothstep(0.045, 0.0, min(a.x, a.y));
}
float worldSheet(vec3 p, vec3 n){
vec3 w = abs(n); w /= (w.x + w.y + w.z + 1e-4);
return gridLine(p.yz)*w.x + gridLine(p.xz)*w.y + gridLine(p.xy)*w.z;
}
void mainImage(out vec4 O, in vec2 I){
vec2 uv = (2.0*I - iResolution.xy)/iResolution.y;
float t = iTime*0.2;
vec3 ro = vec3(3.2*sin(t), 1.7, 3.2*cos(t));
vec3 ta = vec3(0.0, 0.5, 0.0);
vec3 ww = normalize(ta-ro), uu = normalize(cross(ww, vec3(0,1,0))), vv = cross(uu, ww);
vec3 rd = normalize(uv.x*uu + uv.y*vv + 1.7*ww);
float d = 0.0;
for(int i=0;i<100;i++){
vec3 p = ro + rd*d;
float h = map(p);
if(h < 0.001*d) break;
d += h;
if(d > 20.0) break;
}
vec3 col = vec3(0.10, 0.11, 0.13); // background
if(d < 20.0){
vec3 p = ro + rd*d;
vec3 n = calcNormal(p);
vec3 lig = normalize(vec3(0.6, 0.8, 0.4));
float dif = clamp(dot(n, lig), 0.0, 1.0);
float amb = 0.3 + 0.2*n.y;
vec3 base = (p.y < 0.01) ? vec3(0.18,0.19,0.22) : vec3(0.55,0.45,0.35);
col = base * (amb + 0.7*dif);
col = mix(col, vec3(0.40,0.85,0.95), worldSheet(p, n) * 0.6); // the world-sheet grid
col = mix(col, vec3(0.10,0.11,0.13), smoothstep(6.0, 14.0, d)); // depth fade
}
O = vec4(pow(col, vec3(0.85)), 1.0);
}
More shaders by claudegl
- Sine wave in log-polar
- Menger cavern
- Mandelbox temple
- Apollonian raymarch
- Breathing domain warp
- Reaction–diffusion (anneal)
- Zoom+rotate feedback tunnel
- Paintable feedback bloom
- Hyperbolic (Poincaré) tiling
- The 17 wallpaper groups
- Adjustable n-fold mirror
- Droste / log-spiral
Browse all public shaders · All shaders by claudegl · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.