From 9af3e6eeb709963d0b8f9d5c90dd426e79e71629 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 5 Mar 2019 13:30:11 +0100 Subject: [PATCH] Project fixes --- Sources/arm/Config.hx | 8 ++++++-- Sources/arm/MaterialBuilder.hx | 7 ++++++- Sources/arm/Project.hx | 12 ++++++++++-- Sources/arm/ui/UINodes.hx | 21 +++++---------------- Sources/arm/ui/UITrait.hx | 21 +++++++++++---------- Sources/arm/ui/UIView2D.hx | 2 +- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/Sources/arm/Config.hx b/Sources/arm/Config.hx index 6ce7a8ed..365dd450 100644 --- a/Sources/arm/Config.hx +++ b/Sources/arm/Config.hx @@ -19,10 +19,14 @@ class Config { // light.data.raw.strength = 6.5; // } C.rp_supersample = getSuperSampleSize(UITrait.inst.hsupersample.position); - UITrait.inst.ui.g.end(); + + var current = @:privateAccess kha.graphics4.Graphics2.current; + if (current != null) current.end(); + armory.data.Config.save(); armory.renderpath.RenderPathCreator.applyConfig(); - UITrait.inst.ui.g.begin(false); + + if (current != null) current.begin(false); UITrait.inst.ddirty = 2; } diff --git a/Sources/arm/MaterialBuilder.hx b/Sources/arm/MaterialBuilder.hx index bf32b580..93eef916 100644 --- a/Sources/arm/MaterialBuilder.hx +++ b/Sources/arm/MaterialBuilder.hx @@ -623,7 +623,7 @@ class MaterialBuilder { frag.write('fragColor[0] = vec4(n.xy, packFloat(0.0, 1.0), 0.0);'); frag.write('fragColor[1] = vec4(basecol.rgb, packFloat2(1.0, 1.0));'); // occ/spec } - else if (UITrait.inst.viewportMode == 2) { // Normal + else if (UITrait.inst.viewportMode == 2) { // Normal Map frag.write('fragColor[0] = vec4(n.xy, packFloat(0.0, 1.0), 0.0);'); frag.write('fragColor[1] = vec4(ntex.rgb, packFloat2(1.0, 1.0));'); // occ/spec } @@ -643,6 +643,11 @@ class MaterialBuilder { frag.write('fragColor[0] = vec4(n.xy, packFloat(0.0, 1.0), 0.0);'); frag.write('fragColor[1] = vec4(texCoord, 0.0, packFloat2(1.0, 1.0));'); // occ/spec } + else if (UITrait.inst.viewportMode == 7) { // Normal + frag.nAttr = true; + frag.write('fragColor[0] = vec4(n.xy, packFloat(0.0, 1.0), 0.0);'); + frag.write('fragColor[1] = vec4(nAttr, packFloat2(1.0, 1.0));'); // occ/spec + } } frag.write('vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;'); diff --git a/Sources/arm/Project.hx b/Sources/arm/Project.hx index 8a55a455..84e90d40 100644 --- a/Sources/arm/Project.hx +++ b/Sources/arm/Project.hx @@ -126,7 +126,10 @@ class Project { UITrait.inst.paintObject.name = n; UITrait.inst.paintObjects = [UITrait.inst.paintObject]; UITrait.inst.maskHandle.position = 0; - UITrait.inst.materials = [new MaterialSlot()]; + // UITrait.inst.materials = [new MaterialSlot()]; + iron.data.Data.getMaterial("Scene", "Material", function(m:iron.data.MaterialData) { + UITrait.inst.materials = [new MaterialSlot(m)]; + }); UITrait.inst.selectedMaterial = UITrait.inst.materials[0]; UINodes.inst.canvasMap = new Map(); UINodes.inst.canvasBrushMap = new Map(); @@ -167,9 +170,14 @@ class Project { for (file in project.assets) Importer.importTexture(file); + var m0:iron.data.MaterialData = null; + iron.data.Data.getMaterial("Scene", "Material", function(m:iron.data.MaterialData) { + m0 = m; + }); + UITrait.inst.materials = []; for (n in project.material_nodes) { - var mat = new MaterialSlot(); + var mat = new MaterialSlot(m0); UINodes.inst.canvasMap.set(mat, n); UITrait.inst.materials.push(mat); diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 3e40094d..e78ae577 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -580,7 +580,6 @@ class UINodes extends iron.Trait { var con = MaterialBuilder.make_paint(_sd, _matcon); var cdata = con.data; - // if (sc == null) { // from_source is synchronous.. if (sc != null) sc.delete(); @@ -599,8 +598,6 @@ class UINodes extends iron.Trait { m.contexts.push(self); }); - - var dcon = MaterialBuilder.make_depth(_sd, _matcon); var dcdata = dcon.data; // from_source is synchronous.. @@ -614,14 +611,12 @@ class UINodes extends iron.Trait { m.contexts.push(self); }); - - - var smcon = MaterialBuilder.make_depth(_sd, _matcon, true); - var smcdata = smcon.data; + // var smcon = MaterialBuilder.make_depth(_sd, _matcon, true); + // var smcdata = smcon.data; // from_source is synchronous.. - var smsc = new ShaderContext(smcdata, function(sc:ShaderContext){}); - for (c in m.shader.contexts) if (c.raw.name == 'shadowmap') { m.shader.contexts.remove(c); break; } - m.shader.contexts.push(smsc); + // var smsc = new ShaderContext(smcdata, function(sc:ShaderContext){}); + // for (c in m.shader.contexts) if (c.raw.name == 'shadowmap') { m.shader.contexts.remove(c); break; } + // m.shader.contexts.push(smsc); // var smmatcon:TMaterialContext = { // name: "shadowmap" // } @@ -635,12 +630,6 @@ class UINodes extends iron.Trait { UITrait.inst.pdirty = 8; UITrait.inst.ddirty = 8; } - // } - // else { - // sc.raw.vertex_shader = cdata.vertex_shader; - // sc.raw.fragment_shader = cdata.fragment_shader; - // sc.compile(); - // } // }); } diff --git a/Sources/arm/ui/UITrait.hx b/Sources/arm/ui/UITrait.hx index da17c63b..df9979bc 100644 --- a/Sources/arm/ui/UITrait.hx +++ b/Sources/arm/ui/UITrait.hx @@ -397,7 +397,9 @@ class UITrait extends iron.Trait { var shift = kb.down("shift"); var ctrl = kb.down("control"); var alt = kb.down("alt"); + alt = false; // TODO: gets stuck after alt+tab if (kb.started("tab")) { + trace("TAB"); if (ctrl) { // Cycle objects var i = (paintObjects.indexOf(paintObject) + 1) % paintObjects.length; selectPaintObject(paintObjects[i]); @@ -1711,7 +1713,7 @@ class UITrait extends iron.Trait { ui.image(iron.Scene.active.world.probe.radianceMipmaps[0]); } var modeHandle = Id.handle({position: 0}); - viewportMode = ui.combo(modeHandle, ["Render", "Base Color", "Normal", "Occlusion", "Roughness", "Metallic", "TexCoord"], "Mode"); + viewportMode = ui.combo(modeHandle, ["Render", "Base Color", "Normal Map", "Occlusion", "Roughness", "Metallic", "TexCoord", "Normal"], "Mode"); if (modeHandle.changed) { UINodes.inst.parseMeshMaterial(); ddirty = 2; @@ -1868,7 +1870,7 @@ class UITrait extends iron.Trait { } } - if (ui.tab(htab, "File")) { + if (ui.tab(htab, "Export")) { if (ui.panel(Id.handle({selected: true}), "Project", 1)) { ui.row([1/2,1/2]); @@ -2062,7 +2064,7 @@ class UITrait extends iron.Trait { ui.text("Distract Free - F12"); ui.text("Node Editor - Tab"); ui.text("Select Tool - Shift+1-9"); - ui.text("Select Material - Alt+1-9"); + // ui.text("Select Material - Alt+1-9"); ui.text("Next Object - Ctrl+Tab"); ui.text("Auto-Fill - G"); ui.text("Brush Radius - +/-"); @@ -2120,8 +2122,7 @@ class UITrait extends iron.Trait { function renderMenu(g:kha.graphics2.Graphics) { // Draw menu - // if (drawMenu) { - if (false) { + if (drawMenu) { var panelx = iron.App.x() - toolbarw; if (C.ui_layout == 1 && (UINodes.inst.show || UIView2D.inst.show)) panelx = panelx - App.w() - toolbarw; @@ -2145,11 +2146,11 @@ class UITrait extends iron.Trait { ui.t.ELEMENT_H = Std.int(24 * ui.SCALE); if (menuCategory == 0) { - ui.button("New", Left); - ui.button("Open...", Left); - ui.button("Save", Left); - ui.button("Save As...", Left); - ui.button("Import Asset...", Left); + if (ui.button("New", Left)) { Project.projectNew(); ViewportUtil.scaleToBounds(); } + if (ui.button("Open...", Left)) {} + if (ui.button("Save", Left)) {} + if (ui.button("Save As...", Left)) {} + // ui.button("Import Asset...", Left); // ui.button("Export Textures...", Left); // ui.button("Export Mesh...", Left); if (ui.button("Exit", Left)) { kha.System.stop(); } diff --git a/Sources/arm/ui/UIView2D.hx b/Sources/arm/ui/UIView2D.hx index 2c820eec..4464b30a 100644 --- a/Sources/arm/ui/UIView2D.hx +++ b/Sources/arm/ui/UIView2D.hx @@ -167,7 +167,7 @@ class UIView2D extends iron.Trait { ui._x = 3; ui._y = 3; ui._w = ew; - texType = ui.combo(Id.handle({position: texType}), ["Base", "Normal", "ORM"], "Texture"); + texType = ui.combo(Id.handle({position: texType}), ["Base", "Normal Map", "ORM"], "Texture"); ui._x += ew + 3; ui._y = 3; uvmapShow = ui.check(Id.handle({selected: uvmapShow}), "UV Map");