X-Git-Url: https://git.lukelau.me/?a=blobdiff_plain;f=billboardfrag.glsl;h=b4cfd511464569ea23c577cda41a5b261c7ba288;hb=60211392a44ab8b080cfc88035379e92a2fe6f39;hp=2349e4dfef4610558042a9f6b8315e1ac217800a;hpb=31f19438c73b207f506ba0b1187d2de75c166a5b;p=clouds.git diff --git a/billboardfrag.glsl b/billboardfrag.glsl index 2349e4d..b4cfd51 100644 --- a/billboardfrag.glsl +++ b/billboardfrag.glsl @@ -4,9 +4,20 @@ uniform sampler2D tex; in vec2 texCoord; out vec4 FragColor; uniform bool modulate; +uniform bool debug; +uniform bool debugColor; +uniform float debugVal; void main() { + if (debugColor) { + FragColor = color; + return; + } + if (debug) { + FragColor = mix(vec4(1, 1, 1, 0), vec4(1, 0, 0, 1), debugVal); + return; + } // Cf = color from fragment, Ct = color from texture - // Cc = color from texture environment(?) assume to be 0? + // Cc = color from texture environment -- not set, defaults to (0,0,0,0) // Af = alpha from fragment, At = alpha from texture // C = output color, A = output alpha float f = texture(tex, texCoord).r; @@ -14,8 +25,13 @@ void main() { // GL_MODULATE: C // C = Cf * Ct // A = Af * At - FragColor = color * f; + // the +0.06 is a hack to get lighter clouds! + // can be thought of as ambient light + FragColor = color * (f + 0.02); } else { + // "That is, the colors in the frame buffer are multiplied by the + // attenuation ratio of the billboard texture and then the colors in + // the texture are added" // GL_BLEND: // C = Cf * (1-Ct) + Cc * Ct // A = Af * At