瀏覽代碼

added BC1 alpha threshold parameter

Nicolas Cannasse 4 年之前
父節點
當前提交
2ab4830450
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      hxd/fs/Convert.hx

+ 8 - 3
hxd/fs/Convert.hx

@@ -33,8 +33,8 @@ class Convert {
 		return f != null && f != false;
 	}
 
-	function getParam( name : String ) {
-		var f = Reflect.field(params, name);
+	function getParam( name : String ) : Dynamic {
+		var f : Dynamic = Reflect.field(params, name);
 		if( f == null ) throw "Missing required parameter '"+name+"' for converting "+srcPath+" to "+dstPath;
 		return f;
 	}
@@ -221,7 +221,12 @@ class ConvertFNT2BFNT extends Convert {
 class CompressIMG extends Convert {
 
 	override function convert() {
-		command("CompressonatorCLI", ["-silent","-fd",getParam("format"),srcPath,dstPath]);
+		var format = getParam("format");
+		var args = ["-silent"];
+		if( hasParam("alpha") && format == "BC1" )
+			args = args.concat(["-DXT1UseAlpha","1","-AlphaThreshold",""+getParam("alpha")]);
+		args = args.concat(["-fd",""+getParam("format"),srcPath,dstPath]);
+		command("CompressonatorCLI", args);
 	}
 
 	static var _ = Convert.register(new CompressIMG("png,tga,jpg,jpeg","dds"));