Layer stack fixes

This commit is contained in:
luboslenco
2019-03-29 12:05:26 +01:00
parent 29abf36717
commit 8304763eec
7 changed files with 44 additions and 25 deletions
+4 -4
View File
@@ -147,10 +147,10 @@ class App extends iron.Trait {
public static function w():Int {
// Draw material preview
if (UITrait.inst != null && UITrait.inst.materialPreview) return 200;
if (UITrait.inst != null && UITrait.inst.materialPreview) return arm.util.RenderUtil.matPreviewSize;
// Drawing decal preview
if (UITrait.inst != null && UITrait.inst.decalPreview) return 512;
if (UITrait.inst != null && UITrait.inst.decalPreview) return arm.util.RenderUtil.decalPreviewSize;
var res = 0;
if (UINodes.inst == null || UITrait.inst == null) {
@@ -173,10 +173,10 @@ class App extends iron.Trait {
public static function h():Int {
// Draw material preview
if (UITrait.inst != null && UITrait.inst.materialPreview) return 200;
if (UITrait.inst != null && UITrait.inst.materialPreview) return arm.util.RenderUtil.matPreviewSize;
// Drawing decal preview
if (UITrait.inst != null && UITrait.inst.decalPreview) return 512;
if (UITrait.inst != null && UITrait.inst.decalPreview) return arm.util.RenderUtil.decalPreviewSize;
var res = 0;
res = kha.System.windowHeight();
+7 -1
View File
@@ -428,6 +428,11 @@ class MaterialBuilder {
if (layered) {
if (eraser) {
frag.write('fragColor[0] = vec4(basecol, sample_undo.a - str);');
frag.write('matid = 0;');
}
else if (decal) {
frag.write('float invstr = 1.0 - str;');
frag.write('fragColor[0] = vec4(basecol * str + sample_undo.rgb * invstr, max(str, sample_undo.a));');
}
else {
frag.write('fragColor[0] = vec4(basecol, max(str, sample_undo.a));');
@@ -610,7 +615,8 @@ class MaterialBuilder {
frag.write('n /= (abs(n.x) + abs(n.y) + abs(n.z));');
frag.write('n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);');
frag.write('fragColor[0] = vec4(n.x, n.y, packFloat(metallic, roughness), 1.0);');
// float matid = 0.0;
frag.write('fragColor[0] = vec4(n.x, n.y, packFloat(metallic, roughness), 0.0);');
frag.write('fragColor[1] = vec4(basecol.r, basecol.g, basecol.b, packFloat2(occlusion, 1.0));'); // occ/spec
frag.write('fragColor[2] = vec4(0.0, 0.0, 0.0, 0.0);'); // veloc
+1 -1
View File
@@ -20,7 +20,7 @@ class MaterialSlot {
public function new(m:iron.data.MaterialData = null) {
id = ++counter;
image = kha.Image.createRenderTarget(200, 200);
image = kha.Image.createRenderTarget(arm.util.RenderUtil.matPreviewSize, arm.util.RenderUtil.matPreviewSize);
data = m;
}
}
+14 -14
View File
@@ -90,8 +90,8 @@ class RenderPathDeferred {
var t = new RenderTargetRaw();
t.name = "mtex";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = Inc.getHdrFormat();
t.scale = Inc.getSuperSampling();
t.depth_buffer = "mmain";
@@ -101,8 +101,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mbuf";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = Inc.getHdrFormat();
t.scale = Inc.getSuperSampling();
path.createRenderTarget(t);
@@ -111,8 +111,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mgbuffer0";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = "RGBA64";
t.scale = Inc.getSuperSampling();
t.depth_buffer = "mmain";
@@ -122,8 +122,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mgbuffer1";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = "RGBA64";
t.scale = Inc.getSuperSampling();
path.createRenderTarget(t);
@@ -133,8 +133,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mgbuffer2";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = "RGBA64";
t.scale = Inc.getSuperSampling();
path.createRenderTarget(t);
@@ -145,8 +145,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mbufa";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = "RGBA32";
t.scale = Inc.getSuperSampling();
path.createRenderTarget(t);
@@ -154,8 +154,8 @@ class RenderPathDeferred {
{
var t = new RenderTargetRaw();
t.name = "mbufb";
t.width = 200;
t.height = 200;
t.width = arm.util.RenderUtil.matPreviewSize;
t.height = arm.util.RenderUtil.matPreviewSize;
t.format = "RGBA32";
t.scale = Inc.getSuperSampling();
path.createRenderTarget(t);
+3
View File
@@ -198,6 +198,9 @@ class UINodes extends iron.Trait {
UITrait.inst.hwnd1.redraws = 2;
var decal = UITrait.inst.selectedTool == ToolDecal || UITrait.inst.selectedTool == ToolText;
if (decal) RenderUtil.makeDecalPreview();
if (UITrait.inst.autoFillHandle.selected) {
UITrait.inst.layerPreviewDirty = true;
}
}
}
else if (ui.changed && (mstartedlast || mouse.moved) && UITrait.inst.instantMat) {
+6
View File
@@ -601,6 +601,12 @@ class UITrait extends iron.Trait {
UINodes.inst.parsePaintMaterial();
hwnd1.redraws = 2;
headerHandle.redraws = 2;
var current = @:privateAccess kha.graphics4.Graphics2.current;
if (current != null) current.end();
var decal = selectedTool == ToolDecal || selectedTool == ToolText;
if (decal) RenderUtil.makeDecalPreview();
if (current != null) current.begin(false);
}
function selectMaterial2(i:Int) {
+9 -5
View File
@@ -5,9 +5,13 @@ import iron.math.Mat4;
import arm.ui.*;
class RenderUtil {
public static inline var matPreviewSize = 100; // 200
public static inline var decalPreviewSize = 512;
public static function makeDecalPreview() {
if (UITrait.inst.decalImage == null) {
UITrait.inst.decalImage = kha.Image.createRenderTarget(512, 512);
UITrait.inst.decalImage = kha.Image.createRenderTarget(arm.util.RenderUtil.decalPreviewSize, arm.util.RenderUtil.decalPreviewSize);
}
UITrait.inst.decalPreview = true;
@@ -37,8 +41,8 @@ class RenderUtil {
// No jitter
// @:privateAccess iron.Scene.active.camera.frame = 0;
// No resize
@:privateAccess iron.RenderPath.active.lastW = 512;
@:privateAccess iron.RenderPath.active.lastH = 512;
@:privateAccess iron.RenderPath.active.lastW = arm.util.RenderUtil.decalPreviewSize;
@:privateAccess iron.RenderPath.active.lastH = arm.util.RenderUtil.decalPreviewSize;
iron.Scene.active.camera.buildProjection();
iron.Scene.active.camera.buildMatrix();
@@ -108,8 +112,8 @@ class RenderUtil {
// No jitter
// @:privateAccess iron.Scene.active.camera.frame = 0;
// No resize
@:privateAccess iron.RenderPath.active.lastW = 200;
@:privateAccess iron.RenderPath.active.lastH = 200;
@:privateAccess iron.RenderPath.active.lastW = matPreviewSize;
@:privateAccess iron.RenderPath.active.lastH = matPreviewSize;
iron.Scene.active.camera.buildProjection();
iron.Scene.active.camera.buildMatrix();