2
0
Эх сурвалжийг харах

Fixed AlphaMap shader (incorrect channel) (#724)

Sébastien Bénard 5 жил өмнө
parent
commit
b14a755540

+ 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;
 	}