Some typo fixes
[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 bool debugColor;
9 uniform float debugVal;
10 void main() {
11   if (debugColor) {
12     FragColor = color;
13     return;
14   }
15   if (debug) {
16     FragColor = mix(vec4(1, 1, 1, 0), vec4(1, 0, 0, 1), debugVal);
17     return;
18   }
19   // Cf = color from fragment, Ct = color from texture
20   // Cc = color from texture environment -- not set, defaults to (0,0,0,0)
21   // Af = alpha from fragment, At = alpha from texture
22   // C = output color, A = output alpha
23   float f = texture(tex, texCoord).r;
24   if (modulate) { 
25     // GL_MODULATE: C
26     // C = Cf * Ct
27     // A = Af * At
28     // the +0.06 is a hack to get lighter clouds!
29     // can be thought of as ambient light
30     FragColor = color * (f + 0.02);
31   } else {
32     // "That is, the colors in the frame buffer are multiplied by the
33     // attenuation ratio of the billboard texture and then the colors in
34     // the texture are added"
35     // GL_BLEND:
36     // C = Cf * (1-Ct) + Cc * Ct
37     // A = Af * At
38     vec3 C = color.rgb * (1 - f);
39     float A = color.a * f;
40     FragColor = vec4(C, A);
41   }
42 }
43