A ZOOM
GLSL shader by scry · created 2025-07-22 · updated 2025-07-24 · 10s loop · 2 passes
eeee
Tags: 2d
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)
Buffer A (iChannel0)
#define pi acos(-1.)
#define deg pi/180.
#define time iTime*pi/40.
#define R iResolution.xy
#define ar R.x/R.y
vec3 cs = vec3(1.,2.,3.);
// Anti-aliasing quality setting (1-8)
#define AA_QUALITY 4
void render(out vec4 fragColor, in vec2 fragCoord);
// Optimized sampling patterns for different quality levels
vec2 getSampleOffset(int index, int quality) {
if (quality == 1) {
// 1x1 - No AA
return vec2(0.0);
}
else if (quality == 2) {
// 2x2 - 4 samples in rotated grid
vec2 offsets[4] = vec2[4](
vec2(-0.25, -0.25),
vec2( 0.25, -0.25),
vec2(-0.25, 0.25),
vec2( 0.25, 0.25)
);
return offsets[index];
}
else if (quality == 3) {
// 3x3 - 9 samples in regular grid
vec2 offsets[9] = vec2[9](
vec2(-0.33, -0.33), vec2(0.0, -0.33), vec2(0.33, -0.33),
vec2(-0.33, 0.0), vec2(0.0, 0.0), vec2(0.33, 0.0),
vec2(-0.33, 0.33), vec2(0.0, 0.33), vec2(0.33, 0.33)
);
return offsets[index];
}
else if (quality == 4) {
// 4x4 - 16 samples with jittered pattern for better quality
vec2 offsets[16] = vec2[16](
vec2(-0.375, -0.375), vec2(-0.125, -0.375), vec2(0.125, -0.375), vec2(0.375, -0.375),
vec2(-0.375, -0.125), vec2(-0.125, -0.125), vec2(0.125, -0.125), vec2(0.375, -0.125),
vec2(-0.375, 0.125), vec2(-0.125, 0.125), vec2(0.125, 0.125), vec2(0.375, 0.125),
vec2(-0.375, 0.375), vec2(-0.125, 0.375), vec2(0.125, 0.375), vec2(0.375, 0.375)
);
return offsets[index];
}
else if (quality == 5) {
// 5x5 - 25 samples in Poisson disk pattern (better distribution)
vec2 offsets[25] = vec2[25](
vec2( 0.000, 0.000),
vec2(-0.326, -0.406), vec2(-0.840, -0.074), vec2(-0.696, 0.457),
vec2(-0.203, 0.621), vec2( 0.962, -0.195), vec2( 0.473, -0.480),
vec2( 0.519, 0.767), vec2( 0.185, -0.893), vec2( 0.507, 0.064),
vec2( 0.896, 0.412), vec2(-0.322, -0.933), vec2(-0.792, -0.598),
vec2(-0.345, 0.174), vec2( 0.186, 0.469), vec2(-0.897, 0.417),
vec2( 0.054, -0.540), vec2( 0.759, -0.650), vec2(-0.423, 0.886),
vec2( 0.377, 0.927), vec2(-0.715, -0.700), vec2(-0.024, -0.166),
vec2(-0.594, 0.058), vec2( 0.847, -0.469), vec2( 0.351, 0.287)
);
return offsets[index] * 0.4;
}
else if (quality == 6) {
// 6x6 - 36 samples in stratified pattern
float step = 1.0 / 6.0;
int x = index % 6;
int y = index / 6;
return vec2((float(x) + 0.5) * step - 0.5, (float(y) + 0.5) * step - 0.5);
}
else if (quality == 7) {
// 7x7 - 49 samples with quasi-random distribution
float angle = float(index) * 2.3999632297286533; // Golden angle
float radius = sqrt(float(index)) / sqrt(49.0) * 0.5;
return vec2(cos(angle), sin(angle)) * radius;
}
else { // quality == 8
// 8x8 - 64 samples in optimized Halton sequence
float step = 1.0 / 8.0;
int x = index % 8;
int y = index / 8;
// Add slight jitter to avoid regular patterns
float jitterX = fract(sin(float(index) * 12.9898) * 43758.5453) * 0.1 - 0.05;
float jitterY = fract(sin(float(index) * 78.233) * 43758.5453) * 0.1 - 0.05;
return vec2((float(x) + 0.5) * step - 0.5 + jitterX,
(float(y) + 0.5) * step - 0.5 + jitterY);
}
}
int getSampleCount(int quality) {
int counts[8] = int[8](1, 4, 9, 16, 25, 36, 49, 64);
return counts[quality - 1];
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec3 col = vec3(0.);
int sampleCount = getSampleCount(AA_QUALITY);
// Accumulate samples
for (int i = 0; i < sampleCount; i++) {
vec4 renderColor;
render(renderColor, fragCoord + getSampleOffset(i, AA_QUALITY));
col += clamp(renderColor.rgb,0.,1.);
}
// Average the samples
col /= float(sampleCount);
fragColor = vec4(col, 1.0);
}
mat2 r2d(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
void render(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord.xy / iResolution.xy;
vec2 tv = uv;
uv -= 0.5;
uv.x *= ar;
vec3 col = vec3(0.);
//uv = dot(uv,uv)/uv;
//uv = 1./uv;
//uv *= 40.;
float ts = time*0.5;
float fb = abs(fract(ts)-0.5)*2.;
fb = mix(fb,cos(ts*2.*pi)*0.5+0.5,0.9);
uv *= exp((fb)*24.);
//uv *= exp((sin(time*0.1+2.)*0.5+0.5)*24.-2.);
//uv *= 40.;
//uv += 100.;
for (int i=0;i<20;i++) {
float ii = float(i+1);
//uv = uv/dot(uv,uv);
//uv *= 1.+sin(uv*ii*ii*0.1)*0.1*(1./(ii));
uv += sin(uv*ii*0.0000005)*(1500000./ii);
uv *= r2d(deg*45.*0.7);
col += sin(uv.x*ii*0.0000001*ii+cs+2.+ii)*sin(1.+uv.y*ii*0.0000001*ii+cs+ii)*(0.5/(ii)+0.5);
//uv = uv/dot(uv,uv)*.2;
}
col += cos(col+time*10.)*0.1;
col *= 0.3;
col += sin(cs+cos(uv.x*0.00001)*cos(uv.y*0.00001)*12.+time*40.+log(length(uv))*20.)*0.1;
//col += sin((uv.x*1.)+uv.y*1.+time*20.);
//col *= 0.4;
//col += sin(uv.x*20.+cs)*sin(uv.y*20.+cs);
fragColor = vec4(col, 1.0);
}
Image
Not used
More shaders by scry
- Spiral Nebula Nocturne
- Iridescent Ground Ritual
- 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
Browse all public shaders · All shaders by scry · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.