Fix ellipsoids in simulation
[clouds.git] / billboardfrag.glsl
1 #version 400
2 uniform vec4 color;
3 uniform sampler2D tex;
4 in vec2 texCoord;
5 out vec4 FragColor;
6 uniform bool modulate;
7 uniform bool debug;
8 uniform float debugVal;
9 void main() {
10   if (debug) {
11     FragColor = mix(vec4(1, 1, 1, 1), vec4(1, 0, 0, 1), debugVal);
12     return;
13   }
14         // Cf = color from fragment, Ct = color from texture
15         // Cc = color from texture environment -- not set, defaults to (0,0,0,0)
16         // Af = alpha from fragment, At = alpha from texture
17         // C = output color, A = output alpha
18         float f = texture(tex, texCoord).r;
19         if (modulate) { 
20                 // GL_MODULATE: C
21                 // C = Cf * Ct
22                 // A = Af * At                          
23                 FragColor = color * f;
24         } else {
25                 // GL_BLEND:
26                 // C = Cf * (1-Ct) + Cc * Ct
27                 // A = Af * At
28                 vec3 C = color.rgb * (1 - f);
29                 float A = color.a * f;
30                 FragColor = vec4(C, A);
31         }
32 }
33