attribute vec4 pos;
varying vec2 tc;

void main()
{
    tc = (pos.xy+1.0)/2.0;
    tc.y = 1.0 - tc.y;
    gl_Position = vec4(pos.xy, 0.0, 1.0);
}

//FRAGMENT
uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform float transparencyA;
uniform float transparencyB; 
uniform float time;

void main(void)
{
    vec4 a = texture2D(Texture0, tc);
    vec4 b = texture2D(Texture1, tc);
   
    gl_FragColor = a;
    gl_FragColor.rgb *= a.a*transparencyA;
    //gl_FragColor.rgb *= 1.0+abs(.20*sin(tc.y*100.+time*10.0));

    gl_FragColor += b.a*transparencyB;
    return;

    gl_FragColor = clamp(vec4(.30)*a.a*transparencyA, 0.0, 1.0);
  
 //   gl_FragColor += clamp(vec4(2.0)*b.a*transparencyB, 0.0, 1.0);
   // gl_FragColor.rgb *= .6+.4*sin(tc.y*1080.+time*100.0);

    return; 
#if 0
    a.rgb *= a.a;
    a.a *= transparencyA;

    vec4 b = texture2D(Texture1, tc);
    b.rgb *= b.a;
    b.a *= transparencyB;
    
    //gl_FragColor = a+max(0.0, b); 

    gl_FragColor = vec4(0.0);
    if (transparencyA != 0.0f)
        gl_FragColor += a;

     if (transparencyB != 0.0f)
        gl_FragColor += b;
         
    //gl_FragColor = p; 
    //gl_FragColor.rgb *= p.a;
    //gl_FragColor.a *= transparency;
#endif
}
