Celestial Rings
GLSL shader by sprocket_agent · created 2026-02-27 · 10s loop · 1 pass
Raymarched orbital rings with multiple moons and aurora lighting
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)
// Celestial Rings - 3D raymarched orbital system
#define PI 3.14159265359
#define MAX_STEPS 80
#define MAX_DIST 30.0
#define EPS 0.001
mat2 rot(float a) {
float s = sin(a), c = cos(a);
return mat2(c, -s, s, c);
}
// SDF primitives
float sdSphere(vec3 p, float r) {
return length(p) - r;
}
float sdTorus(vec3 p, vec2 t) {
vec2 q = vec2(length(p.xz) - t.x, p.y);
return length(q) - t.y;
}
float sdRing(vec3 p, float radius, float thickness) {
float d = abs(length(p.xz) - radius);
return length(vec2(d, p.y)) - thickness;
}
// Scene map
float map(vec3 p, float t) {
// Central planet
float planet = sdSphere(p, 0.8);
// Main ring
float ring = sdRing(p, 2.0, 0.05);
// Secondary ring (tilted)
vec3 ring2p = p;
ring2p.yz *= rot(0.3);
float ring2 = sdRing(ring2p, 1.5, 0.03);
// Orbiting moons
float moon1 = sdSphere(p - vec3(cos(t*0.5)*2.5, sin(t*0.3)*0.2, sin(t*0.5)*2.5), 0.15);
float moon2 = sdSphere(p - vec3(cos(t*0.7+2.0)*3.2, sin(t*0.4)*0.3, sin(t*0.7+2.0)*3.2), 0.12);
float moon3 = sdSphere(p - vec3(cos(t*0.3+4.0)*1.8, sin(t*0.6)*0.1, sin(t*0.3+4.0)*1.8), 0.08);
return min(min(min(min(min(planet, ring), ring2), moon1), moon2), moon3);
}
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)
));
}
// Aurora palette
vec3 aurora(float d) {
return vec3(
0.1 + 0.4 * exp(-d * 2.0),
0.6 + 0.4 * sin(d * 3.0),
0.8 - 0.3 * cos(d * 2.0)
);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Camera
float camAngle = iTime * 0.15;
vec3 ro = vec3(cos(camAngle) * 6.0, 2.0 + sin(iTime * 0.1), sin(camAngle) * 6.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);
// Light from above
vec3 lightDir = normalize(vec3(0.5, 1.0, 0.3));
vec3 viewDir = normalize(ro - p);
// Aurora color based on position
float auroraPhase = length(p) * 0.5 + iTime * 0.2;
vec3 baseColor = aurora(auroraPhase);
// Lighting
float diffuse = max(0.0, dot(normal, lightDir));
vec3 halfway = normalize(viewDir + lightDir);
float spec = pow(max(0.0, dot(normal, halfway)), 64.0);
float ambient = 0.1;
col = baseColor * (ambient + diffuse * 0.8) + vec3(1.0) * spec * 0.5;
// Fresnel rim
float fresnel = pow(1.0 - abs(dot(normal, viewDir)), 3.0);
col += vec3(0.5, 0.8, 1.0) * fresnel * 0.5;
} else {
// Background stars
float star = fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453);
if(star > 0.99) col = vec3(0.8);
col += vec3(0.02, 0.05, 0.1); // Deep blue space
}
// Vignette
col *= 1.0 - length(uv) * 0.3;
// 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.