Distorted Coordination 3D
GLSL shader by scry · created 2026-02-13 · 10s loop · 2 passes
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. //1 degree
#define time iTime*2.*pi/10. //sin(time) loops 10 seconds
#define R iResolution.xy //shorthand
#define ar R.x/R.y //aspect ratio
#define M iMouse //shorthand
#define xm (M.xy/R) //normalized mouse
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5) //aspect ratio correction
vec3 cs = vec3(1.,2.,3.);
mat2 r2d(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
Buffer A (iChannel0)
// 3D Raymarched version of log-polar chevron pattern
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 sdChevron3D1(vec3 p, vec2 q, float thick) {
vec2 p2 = vec2(abs(p.x), p.y);
vec2 a = p2 - q*clamp(dot(p2,q)/dot(q,q), 0.0, 1.0);
float d2 = length(a) * sign(p2.y*q.x - p2.x*q.y);
return length(vec2(abs(d2), p.z)) - thick;
}
float sdChevron3D(vec3 p, vec2 q, float thick) {
p.x = abs(p.x);
p.xy *= r2d(deg*45.);
p.zy *= r2d(deg*45.);
float d = sdBox(p,vec3(0.09,0.01,0.01));
return d;
}
vec4 map(vec3 p) {
// Convert xz plane to polar coords (like the 2D version)
//p.y = abs(p.y)-1.5;
//p = p/dot(p,p)*2.-0.4;
//p.xy *= r2d(time);
vec2 xz = p.xz;
float r = length(xz);
float ang = atan(xz.x, xz.y);
// Log-polar mapping (mirrors the 2D: uv = vec2(length-0.5, atan), then log)
vec2 lp = vec2(log(r), ang);
float gs = 4.5;
float ug = floor(lp.x * gs - 0.5);
lp.x = (fract(lp.x * gs - 0.5) - 0.5) / gs;
// Alternate direction per ring
lp.y *= mod(ug, 2.) * 2. - 1.;
float s = 10.;
float ag = ug * pi / 2.;
float as2 = sin(lp.y - time * 1. + ag) * 1.;
lp.y -= cos(lp.y - time * 1. + ag) / 1.5;
p.y += sin(lp.y*3.+time)*r*0.1;
lp.y /= pi / 2.;
float gc = lp.y;
s += as2 * 6.;
lp.y = (fract(lp.y * 10.) - 0.5) / s;
// Chevron SDF in the mapped space
float thick = 0.02;
vec3 cp = vec3(lp.x, lp.y, p.y); // map y (height) to the extrusion axis
float d = sdChevron3D(cp, vec2(0.1), thick);
d = min(d, sdChevron3D(cp + vec3(0., 1./s, 0.), vec2(0.1), thick));
d = min(d, sdChevron3D(cp - vec3(0., -2./s, 0.), vec2(0.1), thick));
// Store gc and ug for coloring
//gc = floor(gc + d * 120. + time * 0.);
d = min(d,-sdBox(p,vec3(12.)));
return vec4(gc, ug, r, d*(1.-exp(-r*0.7)));
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.001, 0.0);
return normalize(vec3(
map(p + e.xyy).w - map(p - e.xyy).w,
map(p + e.yxy).w - map(p - e.yxy).w,
map(p + e.yyx).w - map(p - e.yyx).w
));
}
vec2 RM(vec3 ro, vec3 rd) {
float dO = 0.0;
float ii = 0.0;
//rd = rd/dot(rd,rd);
for (int i = 0; i < 580; i++) {
vec3 p = ro + rd * dO;
float dS = map(p).w*0.6;
dO += dS;
ii += 1.0*0.6;
if (dO > 20.0 || dS < 0.001) break;
}
return vec2(dO, ii);
}
vec3 c1_3d(vec2 uv) {
//uv -= 0.5;
//uv.x *= ar;
//uv = fract(uv)-0.5;
//uv = abs(uv);
// Camera setup - orbit around the scene
float camAng = time * 0.3;
float camH = 2.5 + sin(time * 0.5) * 0.5;
float camR = 3.5;
vec3 ro = vec3(sin(camAng) * camR, camH, cos(camAng) * camR);
vec3 target = vec3(0.0, 0.0, 0.0);
vec3 forward = normalize(target - ro);
vec3 right = normalize(cross(forward, vec3(0., 1., 0.)));
vec3 up = cross(right, forward);
vec3 rd = normalize(forward + right * uv.x + up * uv.y);
vec3 col = vec3(0.);
vec3 curRo = ro;
vec3 curRd = rd;
float reflWeight = 1.0;
float metallic = 0.95; // 0.0 = dielectric, 1.0 = full mirror/metal
for (int bounce = 0; bounce < 3; bounce++) {
vec2 res = RM(curRo, curRd);
float t = res.x;
if (t < 20.0) {
vec3 p = curRo + curRd * t;
vec4 m = map(p);
float gc = m.x;
float ug = m.y;
vec3 n = calcNormal(p);
// Lighting
vec3 lightDir = normalize(vec3(1., 2., -1.));
float diff = max(dot(n, lightDir), 0.0);
float amb = 0.15;
float spec = pow(max(dot(reflect(-lightDir, n), -curRd), 0.0), 32.0);
// Color matching the 2D version
vec3 c = vec3(1.0, 0.5, 0.2);
c = sin(c*3. + time * 0. + ug * pi / 2. + gc * pi) * 0.5 + 0.5;
vec3 surfCol = c * (amb + diff * 0.85) + vec3(1.) * spec * mix(0.3, 1.0, metallic);
// Fog
surfCol = mix(surfCol, vec3(0.), 1.0 - exp(-0.015 * t * t));
surfCol += res.y*0.015-0.3;
// Fresnel-based reflectivity
float fres = pow(1.0 - max(dot(n, -curRd), 0.0), 3.0);
float baseRefl = mix(0.05, 0.9, metallic); // metallic surfaces reflect more at all angles
float reflAmount = mix(baseRefl, 1.0, fres);
// Metals tint reflections with their albedo color
vec3 reflTint = mix(vec3(1.0), c, metallic);
col += reflWeight * (1.0 - reflAmount) * surfCol;
reflWeight *= reflAmount;
reflWeight *= mix(1.0, 1.0, metallic); // metals keep energy in reflections
// Setup next bounce
curRd = reflect(curRd, n);
curRo = p + n * 0.01;
} else {
// Sky / background - metallic surfaces can reflect environment
col += reflWeight * mix(vec3(0.0), vec3(0.02, 0.03, 0.05), metallic);
break;
}
if (reflWeight < 0.01) break;
}
col *= 5.;
return col;
}
// --- Original 2D version kept for reference ---
float sdChevron(vec2 p, vec2 q) {
p.x = abs(p.x);
vec2 a = p - q*clamp(dot(p,q)/dot(q,q), 0.0, 1.0);
return abs(length(a) * sign(p.y*q.x - p.x*q.y));
}
/*vec3 c1(vec2 uv) {
uv -= 0.5;
uv.x *= ar;
vec3 col = vec3(0.);
uv *= 1.4;
uv = vec2(length(uv)-0.5,atan(uv.x,uv.y));
uv.x = log(uv.x+0.5);
float gs = 4.5;
float ug = floor(uv.x*gs-0.5);
uv.x = (fract(uv.x*gs-0.5)-0.5)/gs;
uv.y *= mod(ug,2.)*2.-1.;
float s = 10.;
float ag = ug*pi/2.;
float as = sin(uv.y-time*1.+ag)*1.;
uv.y -= cos(uv.y-time*1.+ag)/1.5;
uv.y /= pi/2.;
float gc = uv.y;
s += as*6.;
uv.y = (fract(uv.y*10.)-0.5)/s;
float d = sdChevron(uv, vec2(0.1));
//gc = floor(d*1.+0.9);
d = min((d), sdChevron(uv+vec2(0.,1./s),vec2(0.1)));
d = min((d), sdChevron(uv-vec2(0.,-2./s),vec2(0.1)));
gc = floor(gc+d*120.+time*0.);
//col.r += sin(gc*pi/2.)*0.2;
vec3 c = vec3(1.0, 0.5, 0.2);
c = sin(c+time*0.+ug*pi/2.+gc*pi)*0.5+0.5;
col += mix(c, vec3(0.), smoothstep(0.0, 0.01, abs(d)));
//col += sin(d*20.);
return col;
}*/
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord.xy / iResolution.xy;
vec3 col = vec3(0.);
uv -= 0.5;
uv.x *= ar;
uv *= 0.78;
uv += 0.5;
//uv.y += 0.125;
//col = c1_3d(uv);
for (int i=0;i<8;i++) { // keeping for later
float ii = float(i);
float fi = fract(ii/4.+time/pi/2.);
float f2 = fract(ii/4.+time/pi/2.+0.5);
float afi = abs(fi-0.5)*2.;
float af2 = abs(fi-0.5)*2.;
float nfi = 1.-fi;
float nf2 = 1.-f2;
float naf2 = 1.-af2;
float nafi = 1.-afi;
vec2 av = uv;
//av = cos(av);
nf2 = pow(nf2,5.);
av += sin(uv.yx*8.+ii*pi/3.)*0.5*pow(nf2,4.);
//uv -= 0.5;
//uv *= r2d(deg*45.);
//uv = abs(uv)-0.5;
//uv += 0.5;
av -= 0.5;
av *= r2d(ii*pi/4.+deg*45.*ii);
av = av/dot(av,av);
av += 2.;
av = av/dot(av,av);
//av = fract(av*0.1)-0.5;
//av -= 0.5;
//av += 0.5;
av *= r2d(ii*pi/4.+deg*45.*ii);
av += sin(time/2.+ii*pi/8.)*0.*nf2;
av = mix(av,uv,0.1);
//av = av/dot(av,av);
//uv = abs(uv)-0.1;
//av = abs(av)-0.5;
vec3 c = c1_3d(av)*afi*(sin(ii+sin(uv.x*4.+ii)*sin(uv.y*4.+ii)+time)*0.5+0.5)*afi;
col += c/1.;
}
fragColor = vec4(col, 1.0);
}
Image
Not used
More shaders by scry
- Project_2026-08-15_18-22-06
- Project_2026-08-14_16-45-00
- Project_2026-07-24_15-10-23
- Project_2026-07-15_03-18-26
- Glass of Orange Juice (raymarched)
- Project_2026-07-13_00-53-50
- Project_2026-07-10_16-39-54
- Popcorn ceiling
- Project_2026-06-20_15-32-19
- Project_2026-06-25_12-22-43
- Visual Enhancer
- Project_2026-06-24_11-11-39
Browse all public shaders · All shaders by scry · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.