You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.7 KiB
GLSL
105 lines
2.7 KiB
GLSL
// Author @patriciogv - 2015 - patriciogonzalezvivo.com
|
|
// Modified to use Gingerbread Man chaotic map
|
|
|
|
#ifdef GL_ES
|
|
precision mediump float;
|
|
#endif
|
|
|
|
uniform vec2 u_resolution;
|
|
uniform vec2 u_mouse;
|
|
uniform float u_time;
|
|
|
|
vec2 skew (vec2 st) {
|
|
vec2 r = vec2(0.0);
|
|
r.x = 1.1547*st.x;
|
|
r.y = st.y+0.5*r.x;
|
|
return r;
|
|
}
|
|
|
|
vec3 simplexGrid (vec2 st) {
|
|
vec3 xyz = vec3(0.0);
|
|
|
|
vec2 p = fract(skew(st));
|
|
if (p.x > p.y) {
|
|
xyz.xy = 1.0-vec2(p.x,p.y-p.x);
|
|
xyz.z = p.y;
|
|
} else {
|
|
xyz.yz = 1.0-vec2(p.x-p.y,p.y);
|
|
xyz.x = p.x;
|
|
}
|
|
|
|
return fract(xyz);
|
|
}
|
|
|
|
// Gingerbread Man map
|
|
vec2 gingerbreadMan(vec2 pos, float time) {
|
|
// Classic Gingerbread Man parameters with time modulation
|
|
float a = 0.9 + 0.1 * sin(time * 0.3);
|
|
|
|
// Multiple iterations for chaotic behavior
|
|
vec2 p = pos;
|
|
for(int i = 0; i < 8; i++) {
|
|
float x_new = 1.0 - a * p.y + abs(p.x);
|
|
float y_new = p.x;
|
|
p = vec2(x_new, y_new);
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
// Alternative Gingerbread Man with different parameters
|
|
vec2 gingerbreadMan2(vec2 pos, float time) {
|
|
// More complex version with time-varying parameters
|
|
float a = 0.8 + 0.2 * sin(time * 0.5);
|
|
float b = 1.2 + 0.3 * cos(time * 0.7);
|
|
|
|
vec2 p = pos;
|
|
for(int i = 0; i < 6; i++) {
|
|
float x_new = b * (1.0 + 2.0 * a) - a * p.y + abs(p.x);
|
|
float y_new = p.x;
|
|
p = vec2(x_new, y_new);
|
|
|
|
// Add some noise for extra complexity
|
|
p += 0.01 * sin(p * 10.0 + time);
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
void main() {
|
|
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
|
vec3 color = vec3(0.0);
|
|
|
|
// Scale and center for Gingerbread Man
|
|
vec2 ginger_st = (st - 0.5) * 4.0;
|
|
|
|
// Apply Gingerbread Man map
|
|
vec2 ginger_pos = gingerbreadMan(ginger_st, u_time);
|
|
|
|
// Also get the alternative version
|
|
vec2 ginger_pos2 = gingerbreadMan2(ginger_st, u_time * 1.3);
|
|
|
|
// Scale the space to see the grid
|
|
st *= 8.0;
|
|
|
|
// Use Gingerbread Man output to modulate the simplex grid
|
|
vec2 modulated_st = st + ginger_pos * 0.3;
|
|
|
|
// Create the simplex grid with chaotic modulation
|
|
color = simplexGrid(modulated_st);
|
|
|
|
// Add color based on Gingerbread Man positions
|
|
color.r += 0.3 * (0.5 + 0.5 * sin(length(ginger_pos) * 5.0 + u_time));
|
|
color.g += 0.2 * (0.5 + 0.5 * cos(ginger_pos.x * 3.0 + u_time * 2.0));
|
|
color.b += 0.4 * (0.5 + 0.5 * sin(ginger_pos2.y * 4.0 + u_time * 1.5));
|
|
|
|
// Enhance contrast
|
|
color = mix(color, color * color, 0.3);
|
|
|
|
// Vignette effect
|
|
float vignette = 1.0 - length(st * 0.1);
|
|
color *= vignette * vignette;
|
|
|
|
gl_FragColor = vec4(color, 1.0);
|
|
}
|