Metallic-occlusion-smoothness export

This commit is contained in:
luboslenco
2019-06-19 11:11:06 +02:00
parent 7743fd00e0
commit a32eb5f5d3
2 changed files with 32 additions and 16 deletions
+26 -10
View File
@@ -17,6 +17,16 @@ class Exporter {
var writer = new iron.format.exr.Writer(out, res, res, pixels, bits, type, off);
}
else if (UITrait.inst.formatType == 0) {
var writer = new iron.format.png.Writer(out);
var data =
type == 1 ?
iron.format.png.Tools.build32RGB1(res, res, pixels) :
type == 2 ?
iron.format.png.Tools.build32RRR1(res, res, pixels, off) :
iron.format.png.Tools.build32RGBA(res, res, pixels);
writer.write(data);
}
else {
var writer = new iron.format.jpg.Writer(out);
writer.write({
width: res,
@@ -25,13 +35,6 @@ class Exporter {
pixels: pixels
}, type, off);
}
else {
var writer = new iron.format.png.Writer(out);
var data = type == 1 ?
iron.format.png.Tools.build32RGBA(res, res, pixels) :
iron.format.png.Tools.build32RGBA_(res, res, pixels, off);
writer.write(data);
}
#if kha_krom
Krom.fileSaveBytes(file, out.getBytes().getData());
#end
@@ -44,7 +47,7 @@ class Exporter {
if (f == "") f = "untitled";
var formatType = UITrait.inst.formatType;
var bits = UITrait.inst.bitsHandle.position == 0 ? 8 : 16;
var ext = bits == 16 ? ".exr" : formatType == 0 ? ".jpg" : ".png";
var ext = bits == 16 ? ".exr" : formatType == 0 ? ".png" : ".jpg";
if (StringTools.endsWith(f, ext)) f = f.substr(0, f.length - 4);
var texpaint:kha.Image = null;
var texpaint_nor:kha.Image = null;
@@ -210,9 +213,22 @@ class Exporter {
if (UITrait.inst.isRough) writeTexture(path + "/" + f + "_rough" + ext, pixels, 2, 1);
if (UITrait.inst.isMet) writeTexture(path + "/" + f + "_met" + ext, pixels, 2, 2);
}
else { // UE4
else {
if (UITrait.inst.isOcc || UITrait.inst.isRough || UITrait.inst.isMet) {
writeTexture(path + "/" + f + "_orm" + ext, pixels);
if (UITrait.inst.outputType == 1) { // Unreal 4
writeTexture(path + "/" + f + "_orm" + ext, pixels);
}
else { // Unity 5
var pixels2 = haxe.io.Bytes.alloc(pixels.length);
// 8bit only
for (i in 0...Std.int(pixels.length / 4)) {
pixels2.set(i * 4 , pixels.get(i * 4 + 2));
pixels2.set(i * 4 + 1, pixels.get(i * 4 ));
// pixels2.set(i * 4 + 2, 0);
pixels2.set(i * 4 + 3, 255 - pixels.get(i * 4 + 1));
}
writeTexture(path + "/" + f + "_mos" + ext, pixels2, 3);
}
}
}
+6 -6
View File
@@ -91,7 +91,7 @@ class UITrait extends iron.Trait {
public var colorIdHandle = Id.handle();
public var formatType = 0;
public var formatQuality = 80.0;
public var formatQuality = 100.0;
public var layersExport = 0;
public var outputType = 0;
public var isBase = true;
@@ -485,7 +485,7 @@ class UITrait extends iron.Trait {
arm.App.whandle.redraws = 2;
arm.App.foldersOnly = true;
arm.App.showFilename = true;
UIFiles.filters = bitsHandle.position > 0 ? "exr" : formatType == 0 ? "jpg" : "png";
UIFiles.filters = bitsHandle.position > 0 ? "exr" : formatType == 0 ? "png" : "jpg";
arm.App.filesDone = function(path:String) {
textureExport = true;
textureExportPath = path;
@@ -2268,7 +2268,7 @@ class UITrait extends iron.Trait {
arm.App.foldersOnly = true;
arm.App.showFilename = true;
// var path = 'C:\\Users\\lubos\\Documents\\';
UIFiles.filters = bitsHandle.position > 0 ? "exr" : formatType == 0 ? "jpg" : "png";
UIFiles.filters = bitsHandle.position > 0 ? "exr" : formatType == 0 ? "png" : "jpg";
arm.App.filesDone = function(path:String) {
textureExport = true;
textureExportPath = path;
@@ -2292,17 +2292,17 @@ class UITrait extends iron.Trait {
ui.row([1/2, 1/2]);
if (bitsHandle.position == 0) {
formatType = ui.combo(Id.handle({position: formatType}), ["jpg", "png"], "Format", true);
formatType = ui.combo(Id.handle({position: formatType}), ["png", "jpg"], "Format", true);
}
else {
ui.combo(Id.handle({position: formatType}), ["exr"], "Format", true);
}
ui.enabled = formatType == 0 && bitsHandle.position == 0;
ui.enabled = formatType == 1 && bitsHandle.position == 0;
formatQuality = ui.slider(Id.handle({value: formatQuality}), "Quality", 0.0, 100.0, true, 1);
ui.enabled = true;
ui.row([1/2, 1/2]);
layersExport = ui.combo(Id.handle({position: layersExport}), ["Visible", "Selected"], "Layers", true);
outputType = ui.combo(Id.handle(), ["Generic", "UE4 (ORM)"], "Output", true);
outputType = ui.combo(Id.handle(), ["Generic", "Unreal 4", "Unity 5"], "Output", true);
if (ui.panel(Id.handle({selected: false}), "Channels")) {
ui.row([1/2, 1/2]);