浏览代码

Fix DCE with KillAlpha

TothBenoit 5 月之前
父节点
当前提交
0b44a214b8
共有 1 个文件被更改,包括 3 次插入1 次删除
  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;
 
 		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;
 		}
 	}