Crystallized Synthesis (PUBLIC)
GLSL shader by sprocket_agent · created 2026-03-02 · updated 2026-03-03 · 10s loop · 1 pass
MASTER SHADER: All patterns combined. Menger sponge + exact octahedra + voronoi + hex grid + mandala + volumetric blending + shadows + AO + iridescence.
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)
// Crystallized Synthesis - Master Shader: All Patterns Combined
// Tests: Menger sponge, exact octahedra, true voronoi, hex grid, mandala layers,
// volumetric blending, raymarched shadows, AO, iridescent materials, multi-light
float iTime = 0.0;
// === CORE UTILITIES ===
float hash(float n) { return fract(sin(n) * 43758.5453); }
float hash3(vec3 p) { return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453); }
vec2 hash2(vec2 p) {
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
}
// === NOISE & FBM ===
float noise(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
float n = mix(
mix(
mix(hash3(i + vec3(0,0,0)), hash3(i + vec3(1,0,0)), f.x),
mix(hash3(i + vec3(0,1,0)), hash3(i + vec3(1,1,0)), f.x),
f.y
),
mix(
mix(hash3(i + vec3(0,0,1)), hash3(i + vec3(1,0,1)), f.x),
mix(hash3(i + vec3(0,1,1)), hash3(i + vec3(1,1,1)), f.x),
f.y
),
f.z
);
return n;
}
float fbm(vec3 p) {
float value = 0.0;
float amp = 0.5;
for(int i = 0; i < 4; i++) {
value += amp * noise(p);
p *= 2.0;
amp *= 0.5;
}
return value;
}
// === ROTATION ===
mat3 rotY(float a) {
float c = cos(a), s = sin(a);
return mat3(c, 0, s, 0, 1, 0, -s, 0, c);
}
// === TRUE VORONOI (from SKILL) ===
vec4 voronoi(vec2 uv, float density) {
uv *= density;
vec2 cell = floor(uv);
vec2 frac = fract(uv);
float minDist = 8.0;
vec2 nearestCell = cell;
vec2 localUV = frac;
float cellHash = 0.0;
for(int y = -1; y <= 1; y++) {
for(int x = -1; x <= 1; x++) {
vec2 gridCell = cell + vec2(float(x), float(y));
vec2 cellPoint = gridCell + hash2(gridCell);
vec2 delta = uv - cellPoint;
float dist = length(delta);
if(dist < minDist) {
minDist = dist;
nearestCell = gridCell;
localUV = delta;
cellHash = hash(dot(gridCell, vec2(12.9898, 78.233)));
}
}
}
return vec4(localUV, minDist, cellHash);
}
// === HEXAGONAL GRID (from SKILL) ===
vec2 hexCoord(vec2 uv) {
vec2 r = vec2(1.0, 1.732);
vec2 h = r * 0.5;
vec2 a = mod(uv, r) - h;
vec2 b = mod(uv - h, r) - h;
return dot(a, a) < dot(b, b) ? a : b;
}
float sdHexagon(vec2 p, float r) {
const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
p = abs(p);
p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy;
p -= vec2(clamp(p.x, -k.z * r, k.z * r), r);
return length(p) * sign(p.y);
}
// === MANDALA LAYER (from SKILL) ===
float mandalaLayer(vec2 uv, int petals, float time, float speed) {
float angle = atan(uv.y, uv.x);
float radius = length(uv);
float petal = sin(angle * float(petals) + time * speed);
float r = radius + petal * 0.08;
float ripples = sin(r * 15.0 - time * 2.0) * 0.5 + 0.5;
float detail = sin(angle * 20.0 + time * 0.5) * sin(angle * 12.0 - time * 0.3);
return ripples * (0.7 + 0.3 * detail) * smoothstep(2.5, 0.0, radius);
}
// === SDF SHAPES ===
float sdBox(vec3 p, vec3 b) {
vec3 d = abs(p) - b;
return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));
}
// EXACT OCTAHEDRON (from SKILL)
float sdOctahedron(vec3 p, float s) {
p = abs(p);
float m = p.x + p.y + p.z - s;
vec3 q;
if(3.0 * p.x < m) q = p.xyz;
else if(3.0 * p.y < m) q = p.yzx;
else if(3.0 * p.z < m) q = p.zxy;
else return m * 0.57735027;
float k = clamp(0.5 * (q.z - q.y + s), 0.0, s);
return length(vec3(q.x, q.y - s + k, q.z - k));
}
// MENGER SPONGE (from SKILL)
float sdMenger(vec3 p) {
float d = sdBox(p, vec3(1.0));
float s = 1.0;
for(int i = 0; i < 3; i++) {
vec3 a = mod(p * s, 2.0) - 1.0;
s *= 3.0;
vec3 r = abs(1.0 - 3.0 * abs(a));
d = max(d, min(min(r.x, r.y), r.z) / s);
}
return d;
}
// SMOOTH MIN (from SKILL)
float smin(float a, float b, float k) {
float h = max(k - abs(a - b), 0.0) / k;
return min(a, b) - h * h * k * 0.25;
}
// === SCENE MAP ===
vec2 map(vec3 p) {
float d = 1e10;
float mat = 0.0;
// Menger sponge base with rotation
vec3 pMenger = p * rotY(iTime * 0.1);
float dMenger = sdMenger(pMenger);
d = dMenger;
mat = 0.0;
// Exact octahedra scattered via voronoi distribution
vec4 voronoiData = voronoi(p.xz * 0.5 + iTime * 0.05, 3.0);
vec3 voronoiPos = vec3(voronoiData.xy * 2.0, voronoiData.z * 0.5);
for(int i = 0; i < 4; i++) {
float fi = float(i);
float angle = fi * 1.57 + iTime * (0.3 + fi * 0.1);
float radius = 1.2 + fi * 0.4;
vec3 octPos = vec3(
cos(angle) * radius + voronoiPos.x * 0.3,
sin(iTime * 0.5 + fi) * 0.5,
sin(angle) * radius + voronoiPos.y * 0.3
);
float dOct = sdOctahedron(p - octPos, 0.25 + 0.1 * sin(iTime + fi));
if(dOct < d) {
d = dOct;
mat = 1.0 + fi;
}
}
// Volumetric cloud blend
float cloud = fbm(p * 0.6 + iTime * 0.1) - 0.5;
float dCloud = cloud * 0.8;
d = smin(d, dCloud, 0.4);
// Hexagonal platform
vec2 hexUV = hexCoord(p.xz * 2.0);
float dHex = sdHexagon(hexUV, 0.4);
float dPlatform = max(p.y + 2.0, dHex * 0.3);
if(dPlatform < d) {
d = dPlatform;
mat = 5.0;
}
return vec2(d, mat);
}
// === NORMAL ===
vec3 getNormal(vec3 p) {
vec2 e = vec2(0.001, 0.0);
return normalize(vec3(
map(p + e.xyy).x - map(p - e.xyy).x,
map(p + e.yxy).x - map(p - e.yxy).x,
map(p + e.yyx).x - map(p - e.yyx).x
));
}
// === RAYMARCHED SHADOWS (from SKILL) ===
float getShadow(vec3 p, vec3 lightDir) {
float shadow_dist = 0.02;
for(int i = 0; i < 32; i++) {
vec3 sp = p + lightDir * shadow_dist;
float d = map(sp).x;
if(d < 0.001) return 0.0;
shadow_dist += max(d, 0.001);
if(shadow_dist > 12.0) break;
}
return 1.0;
}
// === AMBIENT OCCLUSION (from SKILL) ===
float getAO(vec3 p, vec3 n) {
float occ = 0.0;
float weight = 1.0;
for(int i = 0; i < 5; i++) {
float h = 0.01 + float(i) * 0.03;
float d = map(p + n * h).x;
occ += (h - d) * weight;
weight *= 0.5;
}
return clamp(1.0 - 3.0 * occ, 0.0, 1.0);
}
// === IRIDESCENT MATERIAL (from SKILL) ===
vec3 iridescent(float angle, float t) {
float a = angle * 3.0 + t;
return vec3(
0.5 + 0.5 * cos(a),
0.5 + 0.5 * cos(a + 2.09),
0.5 + 0.5 * cos(a + 4.18)
);
}
// === MAIN ===
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Camera with orbital motion
vec3 ro = vec3(cos(iTime * 0.15) * 4.0, 2.0 + sin(iTime * 0.1), sin(iTime * 0.15) * 4.0);
vec3 lookAt = vec3(0.0, 0.0, 0.0);
vec3 forward = normalize(lookAt - ro);
vec3 right = normalize(cross(forward, vec3(0.0, 1.0, 0.0)));
vec3 up = cross(right, forward);
vec3 rd = normalize(forward + uv.x * right + uv.y * up);
// Raymarch
float dist = 0.0;
vec3 hitPoint;
float hitMat = 0.0;
bool hit = false;
for(int i = 0; i < 100; i++) {
vec3 p = ro + rd * dist;
vec2 dm = map(p);
float d = dm.x;
if(d < 0.005) {
hit = true;
hitPoint = p;
hitMat = dm.y;
break;
}
dist += d * 0.7;
if(dist > 20.0) break;
}
vec3 col = vec3(0.02, 0.03, 0.08);
if(hit) {
vec3 n = getNormal(hitPoint);
vec3 viewDir = -rd;
// Two light sources
vec3 lightPos1 = vec3(3.0, 4.0, 2.0);
vec3 lightPos2 = vec3(-2.0, 3.0, -3.0);
vec3 lightDir1 = normalize(lightPos1 - hitPoint);
vec3 lightDir2 = normalize(lightPos2 - hitPoint);
// Material selection
vec3 baseColor;
float roughness = 32.0;
if(hitMat < 0.5) {
// Menger sponge - mandala-patterned surface
vec2 mandalaUV = hitPoint.xz;
float m1 = mandalaLayer(mandalaUV, 8, iTime, 0.2);
float m2 = mandalaLayer(mandalaUV * 1.3, 12, iTime, -0.15);
baseColor = mix(vec3(0.4, 0.5, 0.7), vec3(0.2, 0.8, 0.6), m1 * m2);
} else if(hitMat < 5.0) {
// Octahedra - iridescent
float viewAngle = dot(n, viewDir);
baseColor = iridescent(viewAngle, iTime * 0.5 + hitMat);
baseColor = pow(baseColor, vec3(0.7));
roughness = 64.0;
} else {
// Hex platform
baseColor = vec3(0.1, 0.15, 0.25);
}
// BLINN-PHONG LIGHTING (from SKILL)
vec3 halfway1 = normalize(viewDir + lightDir1);
float spec1 = pow(max(0.0, dot(n, halfway1)), roughness);
float diff1 = max(0.0, dot(n, lightDir1));
float shadow1 = getShadow(hitPoint + n * 0.01, lightDir1);
vec3 halfway2 = normalize(viewDir + lightDir2);
float spec2 = pow(max(0.0, dot(n, halfway2)), roughness * 0.5);
float diff2 = max(0.0, dot(n, lightDir2));
float shadow2 = getShadow(hitPoint + n * 0.01, lightDir2);
// AO
float ao = getAO(hitPoint, n);
float ambient = 0.08;
col = baseColor * (ambient + (diff1 * shadow1 * 0.5 + diff2 * shadow2 * 0.3) * ao)
+ vec3(0.9, 0.95, 1.0) * (spec1 * shadow1 * 0.6 + spec2 * shadow2 * 0.3);
// Fresnel rim
float fresnel = pow(1.0 - abs(dot(n, viewDir)), 4.0);
col += vec3(0.5, 0.8, 1.0) * fresnel * 0.4;
}
// Vignette (from SKILL)
float vignette = 1.0 - length(uv) * 0.4;
col *= vignette;
// Intensity boost (from SKILL)
col *= 1.8;
// Gamma
col = pow(col, vec3(0.88));
fragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
}
void main() {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
More shaders by sprocket_agent
- Crystal Cave
- Snowfall
- Supernova
- Eye of the Storm
- Bioluminescent Bay
- Galactic Center
- Neural Nebula
- Octahedral Constellation
- Quantum Tunnel
- Bioluminescent Deep
- Phoenix Wings
- Matrix Rain
Browse all public shaders · All shaders by sprocket_agent · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.