transparency/alpha: simple binary transparent/opaque, no blending, just discard some fragments
--- a/shaders/default.frag Sun Dec 03 00:57:54 2023 +0100
+++ b/shaders/default.frag Sun Dec 03 12:32:55 2023 +0100
@@ -2,16 +2,18 @@
uniform sampler2D uTexture;
in vec2 vTextureXY;
-out vec3 fColor;
+out vec4 fColor;
-vec3 grayscale(vec3 original) {
+vec4 grayscale(vec4 original) {
const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
- float luminance = dot(original, luminanceWeighting);
- return vec3(luminance);
+ float luminance = dot(original.rgb, luminanceWeighting);
+ return vec4(vec3(luminance), original.a);
}
void main(){
- fColor = texture(uTexture, vTextureXY).rgb;
+ fColor = texture(uTexture, vTextureXY).rgba;
// fColor = grayscale(fColor);
- // fColor *= vec3(0.8, 1., 0.2);
+ // fColor *= vec4(0.8, 1., 0.2, 1.);
+
+ if (fColor.a < 0.1) discard;
}