diff options
author | Christoph Helma <helma@in-silico.ch> | 2017-07-21 13:53:27 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2017-07-21 13:53:27 +0200 |
commit | 7605f1ef06957a432c45311158493dbc9acc0c5c (patch) | |
tree | fb99a8228bf2003b2636a387fe64ee3d3a651b92 /shader.frag | |
parent | b5508f0c188e5d5c567c24cad7ee3d8904ecd47a (diff) |
shader reload, shader arrays
Diffstat (limited to 'shader.frag')
-rw-r--r-- | shader.frag | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/shader.frag b/shader.frag index 0494364..4741236 100644 --- a/shader.frag +++ b/shader.frag @@ -5,36 +5,26 @@ precision mediump float; uniform vec2 resolution; uniform float time; -uniform float m; -//uniform sampler2D backbuffer; -uniform sampler2D i0; -uniform sampler2D i1; -uniform sampler2D i2; -uniform sampler2D i3; -uniform float i0ratio; -uniform float i1ratio; -uniform float i2ratio; -uniform float i3ratio; - -uniform float p0; -uniform float p1; -uniform float p3; -uniform float p4; +uniform sampler2D images[4]; +uniform float ratios[4]; +uniform float params[32]; out vec4 fragColor; + float random (in float x) { - return fract(sin(x)*43758.5453123)-0.5; + return fract(sin(x)*43758.5453123)-0.5; } -void main (void) { +vec4 image(int i) { vec2 st = gl_FragCoord.xy/resolution.xy; - vec4 img1 = texture2D(i0,st*vec2(i0ratio,1.)); - vec4 img2 = texture2D(i1,st*vec2(i1ratio,1.)); - vec4 img3 = texture2D(i2,st*vec2(i2ratio,1.)); - vec4 img4 = texture2D(i3,st*vec2(i3ratio,1.)); - img1 = mix(img1,img2,sin(time)); - img2 = mix(img3,img4,cos(time)); - fragColor = mix(img1,img2,p0); - //gl_FragColor = i1; + st.x *= ratios[i]; + st.x += (1-ratios[i])*0.5; + return texture2D(images[i],st); +} + +void main (void) { + vec4 img1 = mix(image(0),image(1),sin(time)); + vec4 img2 = mix(image(2),image(3),cos(time)); + fragColor = mix(img1,img2,params[1]); } |