summaryrefslogtreecommitdiff
path: root/shader.frag
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2018-03-17 20:16:40 +0100
committerChristoph Helma <helma@in-silico.ch>2018-03-17 20:16:40 +0100
commitc5e99b5257dd46c90805ca43881b4665a240b986 (patch)
treea27590d23b60dcd04f016ffddebddf13b87d4b81 /shader.frag
parent1d789e63e8004eaa4755d549c316ba5df32eef58 (diff)
first complete version
Diffstat (limited to 'shader.frag')
-rw-r--r--shader.frag106
1 files changed, 57 insertions, 49 deletions
diff --git a/shader.frag b/shader.frag
index eda981e..60d5e50 100644
--- a/shader.frag
+++ b/shader.frag
@@ -39,6 +39,13 @@ vec2 translate(vec2 st, vec2 amount) {
return st;
}
+vec2 rotate(vec2 st, float angle) {
+ st -= 0.5;
+ st *= angle;
+ st += 0.5;
+ return st;
+}
+
mat2 rotate2d(float _angle){
return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle));
}
@@ -47,88 +54,89 @@ void main (void) {
vec4 img;
vec2 coord;
if (program == 0) {
- coord = zoom(st(),0.5-0.5*(1.0-params[0]));
+ coord = zoom(st(),1.0-0.5*(1.0-params[0]));
img = texture2D(images[0],coord);
- img -= params[1]*(1.0-texture2D(images[1],st()));
+ vec2 tc = st();
+ tc = zoom(tc,2.0);
+ tc.y *= 1.5;
+ tc = translate(tc,vec2(-0.35,0.55));
+ vec4 title = texture2D(images[1],tc);
+ img -= params[1]*0.7*title;
}
else if (program == 1) {
- coord = translate(coord,vec2(0.5,0.5));
- coord = zoom(coord,2.5);
- coord = translate(coord,vec2(-0.5,-0.5));
- //coord = zoom(st(),0.5);
- //coord = zoom(coord,2.1*(1.0-0.5*params[0]));
- //coord = zoom(st(),0.5-0.5*(1.0-params[0]));
- //coord = zoom(st(),(1.0-1.5*params[2]));
- //coord = translate(coord,vec2(0,params[0]));
+ coord = zoom(st(),1.0-0.5*(1.0-params[0]));
img = texture2D(images[0],coord);
- coord = zoom(st(),0.5-0.5*(1.0-params[0]));
+ coord = zoom(st(),1.0-0.5*(1.0-params[2]));
+ coord = translate(coord,vec2(-0.1,-0.1));
vec3 i2 = texture2D(images[2],coord).rgb;
- //img.rgb = pow((1.0-2.0*i2),img.rgb+0.6);
- img.rgb = pow(img.rgb,1.0-i2);
+ img.rgb = pow((1.0-2.3*img.rgb),1.0+(1.0-params[1])*2*i2);
}
else if (program == 2) {
- coord = zoom(st(),(1.0-1.5*params[2]));
+ coord = zoom(st(),1.0-0.5*(1.0-params[2]));
+ coord = translate(coord,vec2(-0.1,-0.1));
+ img = texture2D(images[2],coord);
+ coord = zoom(st(),1.0-0.5*(1.0-params[0]));
+ vec3 i2 = texture2D(images[0],coord).rgb;
+ img.rgb = pow((1.0-2.3*img.rgb),1.0+(1.0-params[1])*2*i2);
+ }
+ else if (program == 3) {
+ coord = zoom(st(),1.0-0.5*(1.0-params[0]));
+ coord = rotate(coord,0.1);
img = texture2D(images[3],coord);
- coord = zoom(st(),0.5*(1.0-0.5*params[0]));
- coord = translate(coord,vec2(0.2,0.15));
+ coord = zoom(st(),0.7-0.5*(1.0-params[2]));
+ coord = translate(coord,vec2(-0.1,0.2));
vec3 i2 = texture2D(images[2],coord).rgb;
- img.rgb = pow((1.0-2.0*i2),params[3]*5*img.rgb);
+ img.rgb = pow((1.0-2.3*img.rgb),params[3]*5*i2);
/*
- 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 += 0.5;
- coord *= rotate2d(params[3]-0.5);
- coord -= 0.5;
- vec3 i2 = texture2D(images[2],coord).rgb;
- img.rgb = pow(img.rgb,5*i2);
- */
- }
- else if (program == 3) {
coord = st() + 0.5;
coord -= 0.5;
img = texture2D(images[3],coord);
coord = zoom(st(),0.5*(1.0-0.5*params[0]));
- //coord = translate(coord,vec2(0.2,0.15));
- //coord = rotate2d(1.0-1.5*params[2])*coord;
coord = rotate2d(sin(ticks))*coord;
- vec3 i2 = texture2D(images[2],coord).rgb;
- img.rgb = pow((1.0-2.0*i2),params[3]*5*img.rgb);
- /*
- */
+ vec3 i2 = texture2D(images[0],coord).rgb;
+ img.rgb = 2.0*pow((1.0-2.0*i2),params[3]*50*img.rgb);
+ */
}
else if (program == 4) {
coord = zoom(st(),(1.0-1.5*params[0]));
- coord = rotate2d(ticks)*coord;
- coord = translate(coord,vec2(0.5,0.5));
img = texture2D(images[3],coord);
coord = zoom(st(),0.5*(1.0-0.5*params[2]));
coord = translate(coord,vec2(0.2,0.15));
- coord = rotate2d(1.0-1.5*params[2])*coord;
- //coord += 0.5;
- //coord *= rotate2d(params[3]-0.5);
- //coord -= 0.5;
+ coord = rotate(coord,-0.1);
vec3 i2 = texture2D(images[2],coord).rgb;
- img.rgb = pow(img.rgb,i2);
+ img.rgb = pow((1.0-2.3*img.rgb),params[3]*5*i2);
}
else if (program == 5) {
coord = zoom(st(),(1.0-1.5*params[0]));
- coord = rotate2d(ticks)*coord;
- coord = translate(coord,vec2(0.5,0.5));
img = texture2D(images[2],coord);
coord = zoom(st(),0.5*(1.0-0.5*params[2]));
- //coord = translate(coord,vec2(0.2,0.15));
- coord = rotate2d(1.0-1.5*params[2])*coord;
- //coord += 0.5;
- //coord *= rotate2d(params[3]-0.5);
- //coord -= 0.5;
+ coord = translate(coord,vec2(0.2,0.15));
+ vec3 i2 = texture2D(images[3],coord).rgb;
+ img.rgb = pow(img.rgb,5*i2);
+ }
+ else if (program == 6) {
+ coord = zoom(st(),(1.0-1.5*params[0]));
+ img = texture2D(images[2],coord);
+ coord = zoom(st(),0.5*(1.0-0.5*params[2]));
+ coord = translate(coord,vec2(0.2,0.15));
vec3 i2 = texture2D(images[3],coord).rgb;
img.rgb = pow(img.rgb,5*i2);
+ vec2 tc = st();
+ tc = zoom(tc,2.0);
+ tc.y *= 1.5;
+ tc = translate(tc,vec2(-0.35,0.15));
+ vec4 title = texture2D(images[1],tc);
+ tc = st();
+ tc = zoom(tc,2.0);
+ tc = translate(tc,vec2(-0.35,0.35));
+ tc.y *= 3.5;
+ vec4 subtitle = texture2D(images[4],tc);
+ img += params[3]*title + subtitle;
}
imageStore(backbuffer,ist(),img);
if (program != 0) {
vec4 feedback = imageLoad(backbuffer,ist());
- img = mix(feedback,img,0.5);
+ img = mix(feedback,img,0.4);
}
fragColor = img;
/*