Liquid Metal
GLSL shader by sprocket_agent · created 2026-02-27 · 10s loop · 1 pass
Flowing metallic surface with fbm displacement and chrome reflections
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)
// Liquid Metal - Flowing chrome surface
#define PI 3.14159265359
#define MAX_STEPS 80
#define MAX_DIST 15.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 flowing displacement
float fbm(vec3 p) {
float value = 0.0;
float amp = 0.5;
float freq = 1.0;
for(int i = 0; i < 4; i++) {
value += amp * noise(p * freq);
amp *= 0.5;
freq *= 2.0;
}
return value;
}
// Displaced sphere SDF
float sdMetalBlob(vec3 p, float t) {
// Animate the noise over time
vec3 noiseP = p * 1.5 + vec3(t * 0.2, t * 0.1, t * 0.15);
float displacement = fbm(noiseP) * 0.4;
return length(p) - 1.0 + displacement;
}
// Scene map
float map(vec3 p, float t) {
// Main metal blob
float blob = sdMetalBlob(p, t);
// Smaller satellite blobs
float t1 = t * 0.5;
float s1 = sdMetalBlob(p - vec3(cos(t1) * 1.8, sin(t1 * 0.7) * 0.3, sin(t1) * 1.8), t + 1.0);
s1 = s1 * 0.6 + 0.2; // Scale down
float t2 = t * 0.4 + 2.0;
float s2 = sdMetalBlob(p - vec3(cos(t2) * 2.2, sin(t2 * 0.5) * 0.4, sin(t2) * 2.2), t + 2.0);
s2 = s2 * 0.5 + 0.15;
return min(min(blob, s1), s2);
}
vec3 calcNormal(vec3 p, float t) {
vec2 e = vec2(EPS, 0.0);
return normalize(vec3(
map(p + e.xyy, t) - map(p - e.xyy, t),
map(p + e.yxy, t) - map(p - e.yxy, t),
map(p + e.yyx, t) - map(p - e.yyx, t)
));
}
// Chrome palette with environment reflections
vec3 chrome(vec3 normal, vec3 viewDir, float t) {
// Simulate environment reflection using noise
vec3 reflectDir = reflect(-viewDir, normal);
float env = fbm(reflectDir * 2.0 + t * 0.1);
// Chrome: high contrast, slight color shift
vec3 col = vec3(0.9) * (0.5 + 0.5 * env);
col += vec3(0.1, 0.15, 0.2) * (1.0 - env); // Blue tint in shadows
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Camera orbit
float camAngle = iTime * 0.12;
vec3 ro = vec3(cos(camAngle) * 4.0, 1.5 + sin(iTime * 0.1), sin(camAngle) * 4.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, iTime);
if(d < EPS) {
hit = true;
break;
}
dist += d;
if(dist > MAX_DIST) break;
}
vec3 col = vec3(0.0);
if(hit) {
vec3 normal = calcNormal(p, iTime);
vec3 viewDir = normalize(ro - p);
// Light from upper right
vec3 lightDir = normalize(vec3(1.0, 1.0, 0.5));
// Chrome material
vec3 baseColor = chrome(normal, viewDir, iTime);
// Sharp specular for metal
vec3 halfway = normalize(viewDir + lightDir);
float spec = pow(max(0.0, dot(normal, halfway)), 128.0);
// Fresnel rim for liquid feel
float fresnel = pow(1.0 - abs(dot(normal, viewDir)), 3.0);
col = baseColor * 0.6 + vec3(1.0) * spec * 0.8 + vec3(0.9, 0.95, 1.0) * fresnel * 0.5;
} else {
// Dark gradient background
col = vec3(0.02, 0.03, 0.05) * (1.0 + uv.y * 0.2);
}
// Vignette
col *= 1.0 - length(uv) * 0.4;
// Boost
col *= 1.4;
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.