summaryrefslogtreecommitdiff
path: root/shader.frag
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2018-02-23 15:31:53 +0100
committerChristoph Helma <helma@in-silico.ch>2018-02-23 15:31:53 +0100
commitcc569501de2559624cf4ee39d064881fbc6e8c25 (patch)
tree30ab41cf2c747017af361fdfe10482864d21165f /shader.frag
parentcbe481d6cb93cc87188d1f791296ba7e74a21b9b (diff)
initial video recording
Diffstat (limited to 'shader.frag')
-rw-r--r--shader.frag66
1 files changed, 54 insertions, 12 deletions
diff --git a/shader.frag b/shader.frag
index 07b7a28..f76c968 100644
--- a/shader.frag
+++ b/shader.frag
@@ -4,14 +4,12 @@ precision mediump float;
#endif
uniform vec2 resolution;
+uniform float time;
uniform float ticks;
uniform int program;
uniform sampler2D images[8];
layout (binding = 0,rgba32f) uniform image2D backbuffer;
-uniform float ratios[4];
-uniform int idx[2];
-uniform float vel[2];
uniform float params[4];
out vec4 fragColor;
@@ -20,19 +18,63 @@ float random (in float x) {
return fract(sin(x)*43758.5453123)-0.5;
}
-vec2 coordinates(int i) {
- vec2 st = gl_FragCoord.xy/resolution.xy;
+vec2 st() {
+ return gl_FragCoord.xy/resolution.xy;
+}
+ivec2 ist() {
+ return ivec2(gl_FragCoord.xy/resolution.xy*resolution);
+}
+
+vec2 zoom(vec2 st, float amount) {
+ st -= 0.5;
+ st *= amount;
+ st += 0.5;
+ return st;
+}
+
+vec2 translate(vec2 st, vec2 amount) {
+ st -= 0.5;
+ st += amount;
+ st += 0.5;
return st;
}
+mat2 rotate2d(float _angle){
+ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle));
+}
+
void main (void) {
- vec4 img;
- vec2 st = coordinates(idx[0]);
- img = texture2D(images[idx[0]],st);
- st = coordinates(idx[1]);
- img = pow(img, texture2D(images[idx[1]],st));
- if (program != 0) {
- img.rgb = img.rgb*params[0];
+ vec4 img;
+ vec2 coord;
+ if (program == 0) {
+ //coord = zoom(st(),0.5*(1.0-params[0]));
+ coord = zoom(st(),sin(time));
+ img = texture2D(images[0],coord);
+ img -= params[1]*(1.0-texture2D(images[1],st()));
+ }
+ else if (program == 1) {
+ coord = zoom(st(),(1.0-1.5*params[0]));
+ img = texture2D(images[3],coord);
+ coord = zoom(st(),0.5*(1.0-0.5*params[2]));
+ vec3 i2 = texture2D(images[2],coord).rgb;
+ img.rgb = pow(img.rgb,5*i2);
}
+ else if (program == 2) {
+ coord = zoom(st(),(1.0-1.5*params[0]));
+ img = texture2D(images[3],coord);
+ coord = zoom(st(),0.5*(1.0-0.5*params[2]));
+ coord *= rotate2d(ticks);
+ vec3 i2 = texture2D(images[2],coord).rgb;
+ img.rgb = pow(img.rgb,5*i2);
+ }
+ vec4 feedback = imageLoad(backbuffer,ist());
+ img = mix(img,feedback,0.5);
+ imageStore(backbuffer,ist(),img);
fragColor = img;
+ /*
+ fragColor = vec4(params[1]);
+ feedback.b += 0.01*cos(time/4.);
+ color.r = max(i.r,feedback.r);
+ */
}
+