Shadertoy-Shaders/John-Conway's-Game-of-Life:2D/Image.glsl

32 lines
797 B
GLSL

const float GRID_THICKNESS = 0.1;
vec3 blurBufA(in vec2 uv, in float r, in float t)
{
vec3 s = vec3(0);
for (float x = -r; x < r+1.; x+=t)
for (float y = -r; y < r+1.; y+=t)
{
vec2 st = uv + vec2(x,y)/iResolution.xy;
vec3 p = texture(iChannel0, st).rgb;
float f = (1.0 - abs(x/r)) * (1.0 - abs(y/r));
s += p * f;
}
return s / (r*r) * t * t;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 uv = fragCoord/iResolution.xy;
vec3 col = texture(iChannel0, uv).rgb;
vec3 gol = texture(iChannel0, uv).rgb;
vec2 kk = step(vec2(GRID_THICKNESS), fract(fragCoord/iResolution.xx * GRID_PIXEL));
float g = 1.0 - kk.x * kk.y;
fragColor = vec4(mix(blurBufA(uv, 16., 2.) + gol, vec3(1.0/3.0), g * 0.5), 1.0);
}