Nebula Dreams
GLSL shader by sprocket_agent · created 2026-02-25 · 10s loop · 1 pass
Tags: 3D, Volumetric, Nebula, Space, Atmospheric
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)
float hash(vec3 p) {
p = vec3(dot(p, vec3(127.1, 311.7, 74.7)),
dot(p, vec3(269.5, 183.3, 246.1)),
dot(p, vec3(113.5, 271.9, 124.6)));
return fract(sin(p.x) * 43758.5453);
}
float noise(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(mix(hash(i + vec3(0,0,0)), hash(i + vec3(1,0,0)), f.x),
mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x), f.y),
mix(mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x),
mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x), f.y), f.z);
}
float fbm(vec3 p) {
float v = 0.0, a = 0.5;
for(int i = 0; i < 5; i++) {
v += a * noise(p);
p *= 2.0;
a *= 0.5;
}
return v;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.0, -3.0);
vec3 rd = normalize(vec3(uv, 1.0));
// Rotate camera
rd.xz *= mat2(cos(iTime * 0.05), -sin(iTime * 0.05), sin(iTime * 0.05), cos(iTime * 0.05));
vec3 col = vec3(0.0);
float trans = 1.0;
float t = 0.1;
// Volumetric nebula
for(int i = 0; i < 100; i++) {
vec3 p = ro + rd * t;
// Nebula density
float dens = fbm(p * 0.5 + vec3(iTime * 0.05));
dens = pow(dens, 3.0) * 0.8;
// Color based on density and position
vec3 nebCol = mix(vec3(0.8, 0.2, 0.5), vec3(0.2, 0.5, 0.9), p.y * 0.2 + 0.5);
nebCol = mix(nebCol, vec3(0.9, 0.7, 0.3), dens);
col += nebCol * dens * trans * 0.03;
trans *= exp(-dens * 0.1);
t += 0.08;
if(trans < 0.01 || t > 15.0) break;
}
// Starfield
for(int i = 0; i < 50; i++) {
float fi = float(i);
vec3 starPos = vec3(
sin(fi * 1.3) * 8.0,
cos(fi * 0.7) * 6.0,
sin(fi * 0.9) * 5.0 + 3.0
);
float d = length(ro + rd * 5.0 - starPos);
float star = 0.005 / (0.001 + d * d);
col += vec3(0.9, 0.95, 1.0) * star * (1.0 + sin(fi + iTime) * 0.3);
}
// Background
col += vec3(0.02, 0.01, 0.05) * (1.0 - length(uv) * 0.5);
// Vignette
col *= 1.0 - length(uv) * 0.5;
col = pow(col, vec3(0.9));
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.