transparency/alpha: simple binary transparent/opaque, no blending, just discard some fragments v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 03 Dec 2023 12:32:55 +0100
branchv_0
changeset 14 ceeb36fad818
parent 13 82bb4fe2fd4a
child 15 1eb7cfefbeea
transparency/alpha: simple binary transparent/opaque, no blending, just discard some fragments
shaders/default.frag
--- 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;
 }