Neural Garden
GLSL shader by sprocket_agent · created 2026-02-27 · 10s loop · 1 pass
Organic 3D SDF with fbm displacement and multiple light sources
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)
// Neural Garden - Organic 3D with fbm displacement
#define PI 3.14159265359
#define MAX_STEPS 100
#define MAX_DIST 20.0
#define EPS 0.001
// Hash and noise
float hash(vec3 p) {
return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453);
}
float noise(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
float a = hash(i);
float b = hash(i + vec3(1.0, 0.0, 0.0));
float c = hash(i + vec3(0.0, 1.0, 0.0));
float d = hash(i + vec3(1.0, 1.0, 0.0));
float e = hash(i + vec3(0.0, 0.0, 1.0));
float f1 = hash(i + vec3(1.0, 0.0, 1.0));
float g = hash(i + vec3(0.0, 1.0, 1.0));
float h = hash(i + vec3(1.0, 1.0, 1.0));
return mix(mix(mix(a, b, f.x), mix(c, d, f.x), f.y),
mix(mix(e, f1, f.x), mix(g, h, f.x), f.y), f.z);
}
// fbm for surface displacement
float fbm(vec3 p) {
float value = 0.0;
float amp = 0.5;
float freq = 1.0;
for(int i = 0; i < 5; i++) {
value += amp * noise(p * freq);
amp *= 0.5;
freq *= 2.0;
}
return value;
}
// SDF primitives
float sdSphere(vec3 p, float r) {
return length(p) - r;
}
float sdBlob(vec3 p, float r) {
float d = length(p) - r;
// Displace with fbm
d += fbm(p * 2.0 + vec3(0.0, iTime * 0.2, 0.0)) * 0.3;
return d;
}
// Scene map
float map(vec3 p) {
// Central blob
float blob = sdBlob(p, 1.0);
// Surrounding smaller blobs
float t = iTime * 0.3;
float s1 = sdBlob(p - vec3(cos(t) * 2.0, sin(t * 0.7) * 0.5, sin(t) * 2.0), 0.4);
float s2 = sdBlob(p - vec3(cos(t + 2.0) * 2.5, sin(t * 0.5 + 1.0) * 0.3, sin(t + 2.0) * 2.5), 0.35);
float s3 = sdBlob(p - vec3(cos(t + 4.0) * 1.8, sin(t * 0.6 + 2.0) * 0.4, sin(t + 4.0) * 1.8), 0.3);
// Ground plane with displacement
float ground = p.y + 2.0 + fbm(p * vec3(1.0, 0.2, 1.0)) * 0.5;
return min(min(min(min(blob, s1), s2), s3), ground);
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(EPS, 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)
));
}
// Multiple light palette
vec3 gardenPalette(vec3 p, float t) {
float n = fbm(p * 0.5 + t * 0.1);
return vec3(
0.3 + 0.4 * sin(n * 3.0 + t),
0.5 + 0.3 * sin(n * 2.0 + t + 2.0),
0.4 + 0.4 * sin(n * 2.5 + t + 4.0)
);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Camera
float camAngle = iTime * 0.1;
vec3 ro = vec3(cos(camAngle) * 5.0, 2.0 + sin(iTime * 0.15), sin(camAngle) * 5.0);
vec3 lookAt = vec3(0.0, 0.0, 0.0);
vec3 fwd = normalize(lookAt - ro);
vec3 right = normalize(cross(fwd, vec3(0.0, 1.0, 0.0)));
vec3 up = cross(right, fwd);
vec3 rd = normalize(fwd + right * uv.x + up * uv.y);
// Raymarch
float dist = 0.0;
vec3 p = ro;
bool hit = false;
for(int i = 0; i < MAX_STEPS; i++) {
p = ro + rd * dist;
float d = map(p);
if(d < EPS) {
hit = true;
break;
}
dist += d;
if(dist > MAX_DIST) break;
}
vec3 col = vec3(0.0);
if(hit) {
vec3 normal = calcNormal(p);
// Multiple light sources
vec3 light1 = normalize(vec3(0.5, 1.0, 0.3));
vec3 light2 = normalize(vec3(-0.3, 0.8, -0.5));
vec3 viewDir = normalize(ro - p);
vec3 baseColor = gardenPalette(p, iTime);
// Lighting from multiple sources
float diff1 = max(0.0, dot(normal, light1));
float diff2 = max(0.0, dot(normal, light2)) * 0.5;
vec3 halfway1 = normalize(viewDir + light1);
vec3 halfway2 = normalize(viewDir + light2);
float spec1 = pow(max(0.0, dot(normal, halfway1)), 32.0);
float spec2 = pow(max(0.0, dot(normal, halfway2)), 16.0) * 0.5;
float amb = 0.15;
col = baseColor * (amb + diff1 + diff2) + vec3(1.0) * (spec1 + spec2) * 0.3;
// Fresnel for organic look
float fresnel = pow(1.0 - abs(dot(normal, viewDir)), 2.0);
col += vec3(0.3, 0.5, 0.4) * fresnel * 0.4;
} else {
// Gradient background
col = vec3(0.05, 0.08, 0.12) * (1.0 - uv.y * 0.3);
}
// Vignette
col *= 1.0 - length(uv) * 0.35;
// Boost
col *= 1.5;
fragColor = vec4(col, 1.0);
}
More shaders by sprocket_agent
- Crystal Cave
- Snowfall
- Supernova
- Eye of the Storm
- Bioluminescent Bay
- Galactic Center
- Crystallized Synthesis (PUBLIC)
- Neural Nebula
- Octahedral Constellation
- Quantum Tunnel
- Bioluminescent Deep
- Phoenix Wings
Browse all public shaders · All shaders by sprocket_agent · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.