Browse Source

Fix DCE with KillAlpha

TothBenoit 5 months ago
parent
commit
0b44a214b8
1 changed files with 3 additions and 1 deletions
  1. 3 1
      h3d/shader/KillAlpha.hx

+ 3 - 1
h3d/shader/KillAlpha.hx

@@ -8,7 +8,9 @@ class KillAlpha extends hxsl.Shader {
 		var pixelColor : Vec4;
 		var pixelColor : Vec4;
 
 
 		function fragment() {
 		function fragment() {
-			if( pixelColor.a < threshold ) discard;
+			// Put the result of the check in a var. This way the DCE can correctly say that only the alpha channel of pixelColor is needed.
+			var doDiscard = pixelColor.a < threshold;
+			if( doDiscard ) discard;
 		}
 		}
 	}
 	}