Dal Platinum
glint · Examples · Tutorials · Gallery
by Dal Platinum
Dal Platinum's dP monogram as a distance field (a parallelogram, rings, boxes and triangles, mirrored) in brushed platinum, pulsing with the kick, with a spectrum halo and light rays.
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
One pass, in GLSL.
fragment shader
#version 300 es
precision highp float;
/*
_______________________________________________________
< The dP logo is by Dal Platinum: twitch.tv/dalplatinum >
-------------------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\ moo
||----w |
|| ||
*/
uniform float time;
uniform vec2 resolution;
uniform vec3 spectrum;
uniform vec3 spectrumIntegrated;
uniform float beat;
uniform int beatCount;
uniform sampler2D fft;
uniform float platinum;
uniform float pulse;
in vec2 v_texcoord;
out vec4 fragColor;
float sdParallelogram( in vec2 p, float wi, float he, float sk )
{
vec2 e = vec2(sk,he);
p = (p.y<0.0)?-p:p;
vec2 w = p - e; w.x -= clamp(w.x,-wi,wi);
vec2 d = vec2(dot(w,w), -w.y);
float s = float(p.x*e.y - p.y*e.x);
p = (s<0.0)?-p:p;
vec2 v = p - vec2(wi,0); v -= e*clamp(dot(v,e)/dot(e,e),-1.0,1.0);
d = min( d, vec2(dot(v,v), wi*he-abs(s)));
return float(sqrt(d.x)*sign(-d.y));
}
float sdBox( in vec2 p, in vec2 b ){vec2 d = abs(p)-b; return float(length(max(d,0.0)) + min(max(d.x,d.y),0.0));}
float opSmoothUnion( float a, float b, float k ){k *= 4.0;float h = max(k-abs(a-b),0.0);return min(a, b) - h*h*0.25/k;}
float opSmoothSubtraction( float a, float b, float k ) {return -opSmoothUnion(a,-b,k);}
float sdTriangle( in vec2 p, in vec2 p0, in vec2 p1, in vec2 p2 )
{
vec2 e0 = p1-p0, e1 = p2-p1, e2 = p0-p2;
vec2 v0 = p -p0, v1 = p -p1, v2 = p -p2;
vec2 pq0 = v0 - e0*clamp( dot(v0,e0)/dot(e0,e0), 0.0, 1.0 );
vec2 pq1 = v1 - e1*clamp( dot(v1,e1)/dot(e1,e1), 0.0, 1.0 );
vec2 pq2 = v2 - e2*clamp( dot(v2,e2)/dot(e2,e2), 0.0, 1.0 );
float s = sign( e0.x*e2.y - e0.y*e2.x );
vec2 d = min(min(vec2(dot(pq0,pq0), s*(v0.x*e0.y-v0.y*e0.x)),
vec2(dot(pq1,pq1), s*(v1.x*e1.y-v1.y*e1.x))),
vec2(dot(pq2,pq2), s*(v2.x*e2.y-v2.y*e2.x)));
return float(-sqrt(d.x)*sign(d.y));
}
vec2 rotate(vec2 p, float angle) {
float cosA = cos(angle);
float sinA = sin(angle);
return mat2(cosA, -sinA, sinA, cosA) * p;
}
float sdDP( vec2 p , float s) { // Needs some functions: rotate, sdParellelogram, sdBox, sdCircle, sdTriangle, opUnion, opSmoothSubtraction
p *= s; // Set the scale, if we fancy it
vec2 rotatedp = rotate(p, 3.141592654/2.0); // flip the uvs 90 degrees so we can put the parallellogram in
float dp = sdParallelogram(rotatedp,0.3,0.1,-0.1); // Parallelogram
for( int i=0; i<2; i++ ) { // Basic loop to run this twice. Don't care about i
dp = min(dp, sdBox(p+vec2(-0.125,-0.3),vec2(0.025,0.10))); // TOP filler box/connecting slot
float ring = opSmoothSubtraction(length(p+vec2(-0.14,-0.1))-0.1,length(p+vec2(-0.14,-0.1))-0.3,0.00001); // big circle with a little circle removed
dp = min(dp, opSmoothSubtraction(sdBox(p+vec2(0.09,0),vec2(0.24,1)), ring,0.0001)); // big box that cuts half of that ^ off
dp = min(dp, sdTriangle(p+vec2(0.036,-0.42), vec2(-0.1,-0.2),vec2(0.1,0.0),vec2(-0.1,0.0))); // Triangle: bottom, topright, topleft (for top one)
dp = min(dp, sdBox(p+vec2(0.036,-0.44),vec2(0.1,0.02))); // box on the triangle
p = rotate(p, 3.141592654); // rotate 180 degrees and run it through again, exactly the same.
}
return dp;
}
vec3 palette(float t) { return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.1, 0.25))); }
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
float kick = beat * pulse;
float t = time * 0.2 + spectrumIntegrated.x * 0.6;
// Background: slow light rays and a floor of spectrum glow.
float a = atan(uv.y, uv.x);
float rays = pow(0.5 + 0.5 * sin(a * 12.0 + t * 2.0), 8.0) * smoothstep(1.2, 0.1, length(uv));
vec3 col = vec3(0.02, 0.025, 0.05) + rays * mix(vec3(0.15, 0.2, 0.35), vec3(0.6, 0.7, 1.0), spectrum.y) * 0.5;
// Spectrum halo around the logo.
float r = length(uv);
float bin = fract(a / 6.28318 + 0.25);
float level = texture(fft, vec2(pow(abs(bin * 2.0 - 1.0), 1.5) * 0.5, 0.25)).r;
float halo = smoothstep(0.012, 0.0, abs(r - (0.62 + level * 0.22)));
col += halo * palette(bin + t * 0.1) * 0.8;
// Dal Platinum's logo, scaled with the kick (sdDP's scale divides, so a bigger s is a smaller logo).
float s = 1.0 / (1.0 + 0.08 * kick + 0.03 * sin(time * 1.3));
float d = sdDP(uv, s) / s;
float px = 1.5 / resolution.y;
vec2 p = uv * s * 2.4;
// Glow around the letters.
col += (0.004 / (abs(d) + 0.004)) * mix(vec3(0.3, 0.4, 0.8), vec3(1.0), kick) * (0.25 + spectrum.x);
// Fill: brushed platinum (a sweeping specular band over fine grain), or Dal Platinum's original colours at platinum = 0.
float grain = fract(sin(dot(floor(p * vec2(300.0, 8.0)), vec2(12.9898, 78.233))) * 43758.5453);
float sweep = smoothstep(0.35, 0.0, abs(p.x * 0.6 + p.y - 2.2 * sin(t * 1.5)));
vec3 metal = vec3(0.55, 0.57, 0.62) + 0.08 * grain + sweep * vec3(0.9) + 0.15 * p.y;
vec3 original = vec3(abs(sin(cos(time + 3.0 * uv.y) * 2.0 * uv.x + time)), abs(cos(sin(time + 2.0 * uv.x) * 3.0 * uv.y + time)), spectrum.x * 4.0);
vec3 fill = mix(original, metal, platinum) * (1.0 + 0.6 * kick);
col = mix(col, fill, smoothstep(px, -px, d));
col *= 1.0 - 0.35 * dot(uv, uv); // vignette
fragColor = vec4(col, 1.0);
}More Starters examples
Instanced cubes · Wireframe waves · Bloom · Terrain flyover · Bass rings · Radial spectrum · Ridgelines · Kaleido pulse