浏览代码

Fixed AlphaMap shader (incorrect channel) (#724)

Sébastien Bénard 5 年之前
父节点
当前提交
b14a755540
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      h3d/shader/AlphaMap.hx

+ 7 - 2
h3d/shader/AlphaMap.hx

@@ -8,14 +8,19 @@ class AlphaMap extends hxsl.Shader {
 		@param var texture : Sampler2D;
 		@param var uvScale : Vec2;
 		@param var uvDelta : Vec2;
+		@const var useAlphaChannel : Bool;
 		function fragment() {
-			pixelColor.a *= texture.get(calculatedUV * uvScale + uvDelta).b;
+			if( useAlphaChannel )
+				pixelColor.a *= texture.get(calculatedUV * uvScale + uvDelta).a;
+			else
+				pixelColor.a *= texture.get(calculatedUV * uvScale + uvDelta).b;
 		}
 	}
 
-	public function new(texture) {
+	public function new(texture, useAlphaChannel=false) {
 		super();
 		uvScale.set(1, 1);
+		this.useAlphaChannel = useAlphaChannel;
 		this.texture = texture;
 	}