less built-in fields
[dd2d.git] / data / shaders / srliquid_color.frag
blob5a075b457aab9c2f0f5ce7720b5f43a47585ddae
1 #version 130
3 uniform sampler2D tex0; // liquid map
4 uniform vec4 liquidColor;
7 void main (void) {
8   vec2 texCoord = gl_TexCoord[0].xy;
9   vec4 clr = texture2D(tex0, texCoord);
10   if (clr.a == 0.0) discard;
11   // if this is top of liquid, brighten it a little
12   clr = liquidColor;
13   float tsy = 1.0/textureSize(tex0, 0).y;
14   texCoord.y -= tsy; // up
15   if (texture2D(tex0, texCoord).a == 0.0) {
16     //clr.a = clamp(clr.a+0.3, 0.0, 1.0);
17     clr.r += clamp(clr.r+0.05, 0.0, 1.0);
18     clr.g += clamp(clr.g+0.05, 0.0, 1.0);
19     //clr = mix(liquidColor, clr, 0.3);
20     //clr = vec4(1.0, 1.0, 1.0, 1.0);
21   }
22   gl_FragColor = clr;
23   //clr.a = 1.0;
24   //gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);