Cellular automata in GLSL+PyQT. Various rulesets can be found by checking out individual commits. http://hut.pm/cellmade_gallery.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.1 KiB

#version 120
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
uniform sampler2D tex;
varying vec4 pos;
uniform float zoom, offsetx, offsety;
uniform int texwidth, texheight;
uniform float hsvshift;
uniform bool hsvactive, diffH, diffV, b1, b2;
void main() {
vec4 col = texture2D(tex, (pos.xy+2)/4);
vec4 colH, colV;
if (diffH) colH = texture2D(tex, (vec2(pos.x, -pos.y)+2)/4);
if (diffV) colV = texture2D(tex, (vec2(-pos.x, pos.y)+2)/4);
if (hsvactive) {
col.rgb = hsv2rgb(vec3(length(col.gb)*10*hsvshift, 1, length(col.rgb)));
if (diffH) colH.rgb = hsv2rgb(vec3(length(colH.gb)*12*hsvshift, 1, length(colH.rgb)));
if (diffV) colV.rgb = hsv2rgb(vec3(length(colV.gb)*12*hsvshift, 1, length(colV.rgb)));
}
if (diffH) {
if (diffV) {
gl_FragColor = abs(col - colV); /* TODO */
}
else {
gl_FragColor = abs(col - colH);
}
}
else if (diffV) {
gl_FragColor = abs(col - colV);
}
else gl_FragColor = col;
}