diff --git a/Sources/Main.hx b/Sources/Main.hx index ef2ce77d..dbdc9a08 100644 --- a/Sources/Main.hx +++ b/Sources/Main.hx @@ -1,21 +1,61 @@ package ; + +import kha.Window; +import kha.WindowOptions; +import kha.WindowMode; +import kha.System; +import iron.Scene; +import iron.RenderPath; +import iron.object.Object; +import arm.render.Inc; +import arm.render.RenderPathDeferred; +import arm.Config; + class Main { - public static inline var projectName = 'untitled - ArmorPaint'; - public static inline var voxelgiVoxelSize = 2.0 / 256; - public static inline var voxelgiHalfExtents = 1; - public static function main() { - armory.system.Starter.main( - 'Scene', - 0, - true, - true, - true, - 1600, - 900, - 1, - true, - arm.render.RenderPathCreator.get - ); - new arm.App(); - } + + public static inline var voxelgiVoxelSize = 2.0 / 256; + public static inline var voxelgiHalfExtents = 1; + + static var tasks:Int; + + public static function main() { + tasks = 1; + #if (arm_config) tasks++; Config.load(function() { tasks--; start(); }); #end + tasks--; start(); + } + + static function start() { + if (tasks > 0) return; + + if (Config.raw == null) Config.raw = {}; + var c = Config.raw; + if (c.window_mode == null) c.window_mode = 0; + if (c.window_resizable == null) c.window_resizable = true; + if (c.window_minimizable == null) c.window_minimizable = true; + if (c.window_maximizable == null) c.window_maximizable = true; + if (c.window_w == null) c.window_w = 1600; + if (c.window_h == null) c.window_h = 900; + if (c.window_scale == null) c.window_scale = 1.0; + if (c.window_msaa == null) c.window_msaa = 1; + if (c.window_vsync == null) c.window_vsync = true; + + var windowMode = c.window_mode == 0 ? WindowMode.Windowed : WindowMode.Fullscreen; + var windowFeatures = None; + if (c.window_resizable) windowFeatures |= FeatureResizable; + if (c.window_maximizable) windowFeatures |= FeatureMaximizable; + if (c.window_minimizable) windowFeatures |= FeatureMinimizable; + + System.start({title: "untitled - ArmorPaint", width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window:Window) { + iron.App.init(function() { + Scene.setActive("Scene", function(object:Object) { + var path = new RenderPath(); + Inc.init(path); + RenderPathDeferred.init(path); + path.commands = RenderPathDeferred.commands; + RenderPath.setActive(path); + new arm.App(); + }); + }); + }); + } } diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index 9c3eedfa..a2498d87 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -121,7 +121,7 @@ class App { color_wheel = image; Nodes.getEnumTexts = getEnumTexts; Nodes.mapEnum = mapEnum; - uibox = new Zui({ font: f, scaleFactor: armory.data.Config.raw.window_scale }); + uibox = new Zui({ font: f, scaleFactor: Config.raw.window_scale }); iron.App.notifyOnInit(function() { // File to open passed as argument @@ -226,7 +226,7 @@ class App { // if (disp.height > 0 && C.window_h > disp.height - 140) { // C.window_h = disp.height - 140; // } - // armory.data.Config.save(); + // Config.save(); } #end diff --git a/Sources/arm/Config.hx b/Sources/arm/Config.hx index 127a6030..cc9a204f 100644 --- a/Sources/arm/Config.hx +++ b/Sources/arm/Config.hx @@ -1,74 +1,100 @@ package arm; +import haxe.Json; +import haxe.io.Bytes; +import iron.data.Data; import arm.ui.UITrait; +import arm.render.Inc; class Config { - public static function init():TConfig { - var C:TConfig = cast armory.data.Config.raw; + public static var raw:TConfig = null; + public static var configLoaded = false; - if (!armory.data.Config.configLoaded) { - C.rp_bloom = true; - C.rp_gi = false; - C.rp_motionblur = false; - C.rp_shadowmap_cube = 0; - C.rp_shadowmap_cascade = 0; - C.rp_ssgi = true; - C.rp_ssr = false; - C.rp_supersample = 1.0; + public static function load(done:Void->Void) { + try { + Data.getBlob('config.arm', function(blob:kha.Blob) { + configLoaded = true; + raw = Json.parse(blob.toString()); + done(); + }); + } + catch(e:Dynamic) { done(); } + } + + public static function save() { + var path = Data.dataPath + 'config.arm'; + var bytes = Bytes.ofString(Json.stringify(raw)); + #if kha_krom + Krom.fileSaveBytes(path, bytes.getData()); + #end + } + + // public static function reset() {} + + public static function init():TConfig { + if (!configLoaded) { + raw.rp_bloom = true; + raw.rp_gi = false; + raw.rp_motionblur = false; + raw.rp_shadowmap_cube = 0; + raw.rp_shadowmap_cascade = 0; + raw.rp_ssgi = true; + raw.rp_ssr = false; + raw.rp_supersample = 1.0; } - if (C.ui_layout == null) C.ui_layout = 0; - if (C.undo_steps == null) C.undo_steps = 4; // Max steps to keep - if (C.keymap == null) { - C.keymap = {}; - C.keymap.action_paint = "left"; - C.keymap.action_rotate = "right"; - C.keymap.action_rotate_light = "middle+shift"; - C.keymap.action_pan = "middle"; - C.keymap.select_material = "shift+number"; - C.keymap.cycle_layers = "ctrl+tab"; - C.keymap.brush_radius = "f"; - C.keymap.brush_ruler = "shift"; - C.keymap.file_new = "ctrl+n"; - C.keymap.file_open = "ctrl+o"; - C.keymap.file_save = "ctrl+s"; - C.keymap.file_save_as = "ctrl+shift+s"; - C.keymap.edit_undo = "ctrl+z"; - C.keymap.edit_redo = "ctrl+shift+z"; - C.keymap.view_reset = "0"; - C.keymap.view_front = "1"; - C.keymap.view_back = "ctrl+1"; - C.keymap.view_right = "3"; - C.keymap.view_left = "ctrl+3"; - C.keymap.view_top = "7"; - C.keymap.view_bottom = "ctrl+7"; - C.keymap.view_camera_type = "5"; - C.keymap.view_orbit_left = "4"; - C.keymap.view_orbit_right = "6"; - C.keymap.view_orbit_top = "8"; - C.keymap.view_orbit_bottom = "2"; - C.keymap.view_orbit_opposite = "9"; - C.keymap.view_distract_free = "f11"; - C.keymap.tool_brush = "b"; - C.keymap.tool_eraser = "e"; - C.keymap.tool_fill = "g"; - C.keymap.tool_decal = "d"; - C.keymap.tool_text = "t"; - C.keymap.tool_clone = "l"; - C.keymap.tool_blur = "u"; - C.keymap.tool_particle = "p"; - C.keymap.tool_bake = "k"; - C.keymap.tool_colorid = "c"; - C.keymap.tool_picker = "v"; - C.keymap.toggle_2d_view = "shift+tab"; - C.keymap.toggle_node_editor = "tab"; - C.keymap.import_assets = "ctrl+shift+i"; - C.keymap.export_textures = "ctrl+shift+e"; - C.keymap.node_search = "space"; + if (raw.ui_layout == null) raw.ui_layout = 0; + if (raw.undo_steps == null) raw.undo_steps = 4; // Max steps to keep + if (raw.keymap == null) { + raw.keymap = {}; + raw.keymap.action_paint = "left"; + raw.keymap.action_rotate = "right"; + raw.keymap.action_rotate_light = "middle+shift"; + raw.keymap.action_pan = "middle"; + raw.keymap.select_material = "shift+number"; + raw.keymap.cycle_layers = "ctrl+tab"; + raw.keymap.brush_radius = "f"; + raw.keymap.brush_ruler = "shift"; + raw.keymap.file_new = "ctrl+n"; + raw.keymap.file_open = "ctrl+o"; + raw.keymap.file_save = "ctrl+s"; + raw.keymap.file_save_as = "ctrl+shift+s"; + raw.keymap.edit_undo = "ctrl+z"; + raw.keymap.edit_redo = "ctrl+shift+z"; + raw.keymap.view_reset = "0"; + raw.keymap.view_front = "1"; + raw.keymap.view_back = "ctrl+1"; + raw.keymap.view_right = "3"; + raw.keymap.view_left = "ctrl+3"; + raw.keymap.view_top = "7"; + raw.keymap.view_bottom = "ctrl+7"; + raw.keymap.view_camera_type = "5"; + raw.keymap.view_orbit_left = "4"; + raw.keymap.view_orbit_right = "6"; + raw.keymap.view_orbit_top = "8"; + raw.keymap.view_orbit_bottom = "2"; + raw.keymap.view_orbit_opposite = "9"; + raw.keymap.view_distract_free = "f11"; + raw.keymap.tool_brush = "b"; + raw.keymap.tool_eraser = "e"; + raw.keymap.tool_fill = "g"; + raw.keymap.tool_decal = "d"; + raw.keymap.tool_text = "t"; + raw.keymap.tool_clone = "l"; + raw.keymap.tool_blur = "u"; + raw.keymap.tool_particle = "p"; + raw.keymap.tool_bake = "k"; + raw.keymap.tool_colorid = "c"; + raw.keymap.tool_picker = "v"; + raw.keymap.toggle_2d_view = "shift+tab"; + raw.keymap.toggle_node_editor = "tab"; + raw.keymap.import_assets = "ctrl+shift+i"; + raw.keymap.export_textures = "ctrl+shift+e"; + raw.keymap.node_search = "space"; } - return C; + return raw; } public static function applyConfig() { @@ -82,8 +108,8 @@ class Config { var current = @:privateAccess kha.graphics4.Graphics2.current; if (current != null) current.end(); - armory.data.Config.save(); - armory.renderpath.RenderPathCreator.applyConfig(); + save(); + Inc.applyConfig(); if (current != null) current.begin(false); UITrait.inst.ddirty = 2; diff --git a/Sources/arm/Tool.hx b/Sources/arm/Tool.hx index 86edf86a..76932019 100644 --- a/Sources/arm/Tool.hx +++ b/Sources/arm/Tool.hx @@ -58,7 +58,7 @@ class Tool { t.width = 0; t.height = 0; t.format = 'R8'; - t.scale = armory.renderpath.Inc.getSuperSampling(); + t.scale = arm.render.Inc.getSuperSampling(); RenderPath.active.createRenderTarget(t); } diff --git a/Sources/arm/nodes/MaterialParser.hx b/Sources/arm/nodes/MaterialParser.hx index dbc14dae..b60218e8 100644 --- a/Sources/arm/nodes/MaterialParser.hx +++ b/Sources/arm/nodes/MaterialParser.hx @@ -39,7 +39,7 @@ class MaterialParser { UITrait.inst.ddirty = 2; #if rp_voxelao - if (MaterialBuilder.heightUsed && armory.data.Config.raw.rp_gi != false) { + if (MaterialBuilder.heightUsed && Config.raw.rp_gi != false) { var sc:ShaderContext = null; for (c in m.shader.contexts) if (c.raw.name == "voxel") { sc = c; break; } if (sc != null) MaterialBuilder.make_voxel(sc); @@ -181,7 +181,7 @@ class MaterialParser { } public static function parseBrush() { - armory.system.Logic.packageName = "arm.nodes.brush"; - var tree = armory.system.Logic.parse(UINodes.inst.canvasBrush, false); + Logic.packageName = "arm.nodes.brush"; + var tree = Logic.parse(UINodes.inst.canvasBrush, false); } } diff --git a/Sources/arm/render/Inc.hx b/Sources/arm/render/Inc.hx new file mode 100644 index 00000000..e0490505 --- /dev/null +++ b/Sources/arm/render/Inc.hx @@ -0,0 +1,131 @@ +package arm.render; + +import iron.RenderPath; + +class Inc { + + static var path:RenderPath; + public static var superSample = 1.0; + + static var pointIndex = 0; + static var spotIndex = 0; + static var lastFrame = -1; + + #if (rp_voxelao && arm_config) + static var voxelsCreated = false; + #end + + public static function init(_path:RenderPath) { + path = _path; + + #if arm_config + var config = Config.raw; + superSample = config.rp_supersample; + #else + + #if (rp_supersampling == 1.5) + superSample = 1.5; + #elseif (rp_supersampling == 2) + superSample = 2.0; + #elseif (rp_supersampling == 4) + superSample = 4.0; + #end + + #end + } + + public static function applyConfig() { + #if arm_config + var config = Config.raw; + if (superSample != config.rp_supersample) { + superSample = config.rp_supersample; + for (rt in path.renderTargets) { + if (rt.raw.width == 0 && rt.raw.scale != null) { + rt.raw.scale = getSuperSampling(); + } + } + path.resize(); + } + // Init voxels + #if rp_voxelao + if (!voxelsCreated) initGI(); + #end + #end // arm_config + } + + #if rp_voxelao + public static function initGI(tname = "voxels") { + #if arm_config + var config = Config.raw; + if (config.rp_gi != true || voxelsCreated) return; + voxelsCreated = true; + #end + + var t = new RenderTargetRaw(); + t.name = tname; + t.format = "R8"; + var res = getVoxelRes(); + var resZ = getVoxelResZ(); + t.width = res; + t.height = res; + t.depth = Std.int(res * resZ); + t.is_image = true; + t.mipmaps = true; + path.createRenderTarget(t); + + #if arm_voxelgi_temporal + { + var tB = new RenderTargetRaw(); + tB.name = t.name + "B"; + tB.format = t.format; + tB.width = t.width; + tB.height = t.height; + tB.depth = t.depth; + tB.is_image = t.is_image; + tB.mipmaps = t.mipmaps; + path.createRenderTarget(tB); + } + #end + } + #end + + public static inline function getVoxelRes():Int { + #if (rp_voxelgi_resolution == 512) + return 512; + #elseif (rp_voxelgi_resolution == 256) + return 256; + #elseif (rp_voxelgi_resolution == 128) + return 128; + #elseif (rp_voxelgi_resolution == 64) + return 64; + #elseif (rp_voxelgi_resolution == 32) + return 32; + #else + return 0; + #end + } + + public static inline function getVoxelResZ():Float { + #if (rp_voxelgi_resolution_z == 1.0) + return 1.0; + #elseif (rp_voxelgi_resolution_z == 0.5) + return 0.5; + #elseif (rp_voxelgi_resolution_z == 0.25) + return 0.25; + #else + return 0.0; + #end + } + + public static inline function getSuperSampling():Float { + return superSample; + } + + public static inline function getHdrFormat():String { + #if rp_hdr + return "RGBA64"; + #else + return "RGBA32"; + #end + } +} diff --git a/Sources/arm/render/RenderPathCreator.hx b/Sources/arm/render/RenderPathCreator.hx deleted file mode 100644 index ede6735e..00000000 --- a/Sources/arm/render/RenderPathCreator.hx +++ /dev/null @@ -1,25 +0,0 @@ -package arm.render; - -import iron.RenderPath; -import armory.renderpath.Inc; - -class RenderPathCreator { - - public static var drawMeshes:Void->Void = armory.renderpath.RenderPathDeferred.drawMeshes; - public static var applyConfig:Void->Void = armory.renderpath.RenderPathDeferred.applyConfig; - - #if (rp_gi != "Off") - public static var voxelFrame = 0; - public static var voxelFreq = 6; // Revoxelizing frequency - #end - - public static var finalTarget:RenderTarget = null; - - public static function get():RenderPath { - var path = new RenderPath(); - Inc.init(path); - RenderPathDeferred.init(path); - path.commands = RenderPathDeferred.commands; - return path; - } -} diff --git a/Sources/arm/render/RenderPathDeferred.hx b/Sources/arm/render/RenderPathDeferred.hx index d54883f1..0e60cd74 100644 --- a/Sources/arm/render/RenderPathDeferred.hx +++ b/Sources/arm/render/RenderPathDeferred.hx @@ -8,7 +8,6 @@ import iron.math.Vec4; import iron.math.Quat; import iron.system.Input; import iron.object.MeshObject; -import armory.renderpath.Inc; import arm.util.ViewportUtil; import arm.util.RenderUtil; import arm.ui.UITrait; @@ -23,6 +22,8 @@ class RenderPathDeferred { #if rp_voxelao static var voxels = "voxels"; static var voxelsLast = "voxels"; + public static var voxelFrame = 0; + public static var voxelFreq = 6; // Revoxelizing frequency #end static var taaFrame = 0; static var lastX = -1.0; @@ -32,14 +33,319 @@ class RenderPathDeferred { path = _path; - armory.renderpath.RenderPathDeferred.init(path); + #if (rp_background == "World") + { + path.loadShader("shader_datas/world_pass/world_pass"); + } + #end + + #if rp_voxelao + { + Inc.initGI(); + path.loadShader("shader_datas/deferred_light/deferred_light_VoxelAOvar"); + } + #end + + { + path.createDepthBuffer("main", "DEPTH24"); + + var t = new RenderTargetRaw(); + t.name = "gbuffer0"; + t.width = 0; + t.height = 0; + t.format = "RGBA64"; + t.scale = Inc.getSuperSampling(); + t.depth_buffer = "main"; + path.createRenderTarget(t); + } + + { + var t = new RenderTargetRaw(); + t.name = "tex"; + t.width = 0; + t.height = 0; + t.format = Inc.getHdrFormat(); + t.scale = Inc.getSuperSampling(); + t.depth_buffer = "main"; + path.createRenderTarget(t); + } + + { + var t = new RenderTargetRaw(); + t.name = "buf"; + t.width = 0; + t.height = 0; + t.format = Inc.getHdrFormat(); + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + + { + var t = new RenderTargetRaw(); + t.name = "gbuffer1"; + t.width = 0; + t.height = 0; + t.format = "RGBA64"; + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + + #if rp_gbuffer2 + { + var t = new RenderTargetRaw(); + t.name = "gbuffer2"; + t.width = 0; + t.height = 0; + t.format = "RGBA64"; + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + + { + var t = new RenderTargetRaw(); + t.name = "taa"; + t.width = 0; + t.height = 0; + t.format = "RGBA32"; + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + #end + + path.loadShader("shader_datas/deferred_light/deferred_light"); + + #if ((rp_ssgi == "RTGI") || (rp_ssgi == "RTAO")) + { + path.loadShader("shader_datas/ssgi_pass/ssgi_pass"); + path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_x"); + path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_y"); + } + #end + + #if ((rp_ssgi != "Off") || rp_volumetriclight) + { + var t = new RenderTargetRaw(); + t.name = "singlea"; + t.width = 0; + t.height = 0; + t.format = "R8"; + t.scale = Inc.getSuperSampling(); + #if rp_ssgi_half + t.scale *= 0.5; + #end + path.createRenderTarget(t); + } + { + var t = new RenderTargetRaw(); + t.name = "singleb"; + t.width = 0; + t.height = 0; + t.format = "R8"; + t.scale = Inc.getSuperSampling(); + #if rp_ssgi_half + t.scale *= 0.5; + #end + path.createRenderTarget(t); + } + #end + + #if ((rp_antialiasing == "SMAA") || (rp_antialiasing == "TAA")) + { + var t = new RenderTargetRaw(); + t.name = "bufa"; + t.width = 0; + t.height = 0; + t.format = "RGBA32"; + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + { + var t = new RenderTargetRaw(); + t.name = "bufb"; + t.width = 0; + t.height = 0; + t.format = "RGBA32"; + t.scale = Inc.getSuperSampling(); + path.createRenderTarget(t); + } + #end + + #if rp_compositornodes + { + path.loadShader("shader_datas/compositor_pass/compositor_pass"); + } + #end + + #if ((!rp_compositornodes) || (rp_antialiasing == "TAA") || (rp_motionblur == "Camera") || (rp_motionblur == "Object")) + { + path.loadShader("shader_datas/copy_pass/copy_pass"); + } + #end + + #if ((rp_antialiasing == "SMAA") || (rp_antialiasing == "TAA")) + { + path.loadShader("shader_datas/smaa_edge_detect/smaa_edge_detect"); + path.loadShader("shader_datas/smaa_blend_weight/smaa_blend_weight"); + path.loadShader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend"); + + #if (rp_antialiasing == "TAA") + { + path.loadShader("shader_datas/taa_pass/taa_pass"); + } + #end + } + #end + + #if (rp_supersampling == 4) + { + path.loadShader("shader_datas/supersample_resolve/supersample_resolve"); + } + #end + + #if rp_volumetriclight + { + path.loadShader("shader_datas/volumetric_light/volumetric_light"); + path.loadShader("shader_datas/blur_bilat_pass/blur_bilat_pass_x"); + path.loadShader("shader_datas/blur_bilat_blend_pass/blur_bilat_blend_pass_y"); + } + #end + + #if rp_water + { + path.loadShader("shader_datas/water_pass/water_pass"); + path.loadShader("shader_datas/copy_pass/copy_pass"); + } + #end + + #if rp_bloom + { + var t = new RenderTargetRaw(); + t.name = "bloomtex"; + t.width = 0; + t.height = 0; + t.scale = 0.25; + t.format = Inc.getHdrFormat(); + path.createRenderTarget(t); + } + + { + var t = new RenderTargetRaw(); + t.name = "bloomtex2"; + t.width = 0; + t.height = 0; + t.scale = 0.25; + t.format = Inc.getHdrFormat(); + path.createRenderTarget(t); + } + + { + path.loadShader("shader_datas/bloom_pass/bloom_pass"); + path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x"); + path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y"); + path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y_blend"); + } + #end + + #if rp_autoexposure + { + var t = new RenderTargetRaw(); + t.name = "histogram"; + t.width = 1; + t.height = 1; + t.format = Inc.getHdrFormat(); + path.createRenderTarget(t); + } + + { + path.loadShader("shader_datas/histogram_pass/histogram_pass"); + } + #end + + #if rp_sss + { + path.loadShader("shader_datas/sss_pass/sss_pass_x"); + path.loadShader("shader_datas/sss_pass/sss_pass_y"); + } + #end + + #if (rp_ssr_half || rp_ssgi_half) + { + { + path.loadShader("shader_datas/downsample_depth/downsample_depth"); + var t = new RenderTargetRaw(); + t.name = "half"; + t.width = 0; + t.height = 0; + t.scale = Inc.getSuperSampling() * 0.5; + t.format = "R32"; // R16 + path.createRenderTarget(t); + } + } + #end + + #if rp_ssr + { + path.loadShader("shader_datas/ssr_pass/ssr_pass"); + path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x"); + path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend"); + + #if rp_ssr_half + { + var t = new RenderTargetRaw(); + t.name = "ssra"; + t.width = 0; + t.height = 0; + t.scale = Inc.getSuperSampling() * 0.5; + t.format = Inc.getHdrFormat(); + path.createRenderTarget(t); + } + { + var t = new RenderTargetRaw(); + t.name = "ssrb"; + t.width = 0; + t.height = 0; + t.scale = Inc.getSuperSampling() * 0.5; + t.format = Inc.getHdrFormat(); + path.createRenderTarget(t); + } + #end + } + #end + + #if ((rp_motionblur == "Camera") || (rp_motionblur == "Object")) + { + #if (rp_motionblur == "Camera") + { + path.loadShader("shader_datas/motion_blur_pass/motion_blur_pass"); + } + #else + { + path.loadShader("shader_datas/motion_blur_veloc_pass/motion_blur_veloc_pass"); + } + #end + } + #end + + #if arm_config + { + var t = new RenderTargetRaw(); + t.name = "empty_white"; + t.width = 1; + t.height = 1; + t.format = 'R8'; + var rt = new RenderTarget(t); + var b = haxe.io.Bytes.alloc(1); + b.set(0, 255); + rt.image = kha.Image.fromBytes(b, t.width, t.height, kha.graphics4.TextureFormat.L8); + path.renderTargets.set(t.name, rt); + } + #end { var t = new RenderTargetRaw(); t.name = "taa2"; t.width = 0; t.height = 0; - t.displayp = Inc.getDisplayp(); t.format = "RGBA32"; t.scale = Inc.getSuperSampling(); path.createRenderTarget(t); @@ -184,7 +490,7 @@ class RenderPathDeferred { if (System.windowWidth() == 0 || System.windowHeight() == 0) return; - var ssaa4 = armory.data.Config.raw.rp_supersample == 4 ? true : false; + var ssaa4 = Config.raw.rp_supersample == 4 ? true : false; var mouse = Input.getMouse(); var mx = lastX; @@ -379,7 +685,7 @@ class RenderPathDeferred { #if ((rp_ssgi == "RTGI") || (rp_ssgi == "RTAO")) { - var ssgi = armory.data.Config.raw.rp_ssgi != false && UITrait.inst.cameraType == 0; + var ssgi = Config.raw.rp_ssgi != false && UITrait.inst.cameraType == 0; if (ssgi && UITrait.inst.ddirty > 0 && taaFrame > 0) { path.setTarget("singlea"); path.bindTarget("_main", "gbufferD"); @@ -404,12 +710,12 @@ class RenderPathDeferred { // Voxels #if rp_voxelao - if (armory.data.Config.raw.rp_gi != false) + if (Config.raw.rp_gi != false) { var voxelize = path.voxelize() && UITrait.inst.ddirty > 0 && taaFrame > 0; #if arm_voxelgi_temporal - voxelize = ++RenderPathCreator.voxelFrame % RenderPathCreator.voxelFreq == 0; + voxelize = ++voxelFrame % voxelFreq == 0; if (voxelize) { voxels = voxels == "voxels" ? "voxelsB" : "voxels"; @@ -447,7 +753,7 @@ class RenderPathDeferred { path.bindTarget("gbuffer1", "gbuffer1"); #if (rp_ssgi != "Off") { - var ssgi = armory.data.Config.raw.rp_ssgi != false && UITrait.inst.cameraType == 0; + var ssgi = Config.raw.rp_ssgi != false && UITrait.inst.cameraType == 0; if (ssgi && taaFrame > 0) { path.bindTarget("singlea", "ssaotex"); } @@ -458,7 +764,7 @@ class RenderPathDeferred { #end var voxelao_pass = false; #if rp_voxelao - if (armory.data.Config.raw.rp_gi != false) + if (Config.raw.rp_gi != false) { voxelao_pass = true; path.bindTarget(voxels, "voxels"); @@ -504,7 +810,7 @@ class RenderPathDeferred { #if rp_bloom { - if (armory.data.Config.raw.rp_bloom != false) { + if (Config.raw.rp_bloom != false) { path.setTarget("bloomtex"); path.bindTarget("tex", "tex"); path.drawShader("shader_datas/bloom_pass/bloom_pass"); @@ -563,7 +869,7 @@ class RenderPathDeferred { #if rp_ssr { - if (armory.data.Config.raw.rp_ssr != false) { + if (Config.raw.rp_ssr != false) { var targeta = "buf"; var targetb = "gbuffer1"; @@ -589,7 +895,7 @@ class RenderPathDeferred { #if ((rp_motionblur == "Camera") || (rp_motionblur == "Object")) { - if (armory.data.Config.raw.rp_motionblur != false) { + if (Config.raw.rp_motionblur != false) { path.setTarget("buf"); path.bindTarget("tex", "tex"); path.bindTarget("gbuffer0", "gbuffer0"); @@ -618,7 +924,6 @@ class RenderPathDeferred { } #end - RenderPathCreator.finalTarget = path.currentTarget; path.setTarget("buf"); path.bindTarget("tex", "tex"); @@ -750,7 +1055,7 @@ class RenderPathDeferred { } // - RenderPathCreator.drawMeshes(); + path.drawMeshes("mesh"); #if rp_decals { diff --git a/Sources/arm/render/RenderPathPaint.hx b/Sources/arm/render/RenderPathPaint.hx index bb263b6e..235bd78f 100644 --- a/Sources/arm/render/RenderPathPaint.hx +++ b/Sources/arm/render/RenderPathPaint.hx @@ -2,7 +2,6 @@ package arm.render; import iron.object.MeshObject; import iron.Scene; -import armory.renderpath.Inc; import arm.ui.UITrait; import arm.Tool; diff --git a/Sources/arm/render/RenderPathPreview.hx b/Sources/arm/render/RenderPathPreview.hx index e022f3f1..7173b741 100644 --- a/Sources/arm/render/RenderPathPreview.hx +++ b/Sources/arm/render/RenderPathPreview.hx @@ -24,8 +24,7 @@ class RenderPathPreview { #end path.clearTarget(null, 1.0); - - RenderPathCreator.drawMeshes(); + path.drawMeshes("mesh"); // --- // Deferred light @@ -88,8 +87,7 @@ class RenderPathPreview { #end path.clearTarget(null, 1.0); - - RenderPathCreator.drawMeshes(); + path.drawMeshes("mesh"); // --- // Deferred light diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index 07019e24..fa6b99d8 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -14,7 +14,7 @@ class Uniforms { iron.object.Uniforms.externalFloatLinks = [linkFloat]; iron.object.Uniforms.externalVec2Links = [linkVec2]; iron.object.Uniforms.externalVec4Links = [linkVec4]; - iron.object.Uniforms.externalTextureLinks.push(linkTex); + iron.object.Uniforms.externalTextureLinks = [linkTex]; } public static function linkFloat(object:Object, mat:MaterialData, link:String):Null { @@ -140,6 +140,16 @@ class Uniforms { else if (link == "_texparticle") { return RenderPath.active.renderTargets.get("texparticle").image; } + #if arm_ltc + else if (link == "_ltcMat") { + if (arm.data.ConstData.ltcMatTex == null) arm.data.ConstData.initLTC(); + return arm.data.ConstData.ltcMatTex; + } + else if (link == "_ltcMag") { + if (arm.data.ConstData.ltcMagTex == null) arm.data.ConstData.initLTC(); + return arm.data.ConstData.ltcMagTex; + } + #end return null; } } diff --git a/Sources/arm/ui/TabPreferences.hx b/Sources/arm/ui/TabPreferences.hx index b0ff8865..04cd9780 100644 --- a/Sources/arm/ui/TabPreferences.hx +++ b/Sources/arm/ui/TabPreferences.hx @@ -28,7 +28,7 @@ class TabPreferences { UITrait.inst.headerh = Std.int(UITrait.defaultHeaderH * App.C.window_scale); UITrait.inst.menubarw = Std.int(215 * App.C.window_scale); App.resize(); - armory.data.Config.save(); + Config.save(); UITrait.inst.setIconScale(); } UITrait.inst.hscaleWasChanged = hscale.changed; @@ -37,7 +37,7 @@ class TabPreferences { App.C.ui_layout = ui.combo(layHandle, ["Right", "Left"], "Layout", true); if (layHandle.changed) { App.resize(); - armory.data.Config.save(); + Config.save(); } var themeHandle = Id.handle({position: 0}); var themes = ["Dark", "Light"]; @@ -83,7 +83,7 @@ class TabPreferences { } History.reset(); ui.g.begin(false); - armory.data.Config.save(); + Config.save(); } UITrait.inst.brushBias = ui.slider(Id.handle({value: UITrait.inst.brushBias}), "Paint Bias", 0.0, 1.0, true); @@ -129,7 +129,7 @@ class TabPreferences { ui.row([1/2, 1/2]); var vsyncHandle = Id.handle({selected: App.C.window_vsync}); App.C.window_vsync = ui.check(vsyncHandle, "VSync"); - if (vsyncHandle.changed) armory.data.Config.save(); + if (vsyncHandle.changed) Config.save(); ui.combo(UITrait.inst.hsupersample, ["1.0x", "1.5x", "2.0x", "4.0x"], "Super Sample", true); if (UITrait.inst.hsupersample.changed) Config.applyConfig(); ui.row([1/2, 1/2]); diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 20f27ac8..370fadf5 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -81,7 +81,7 @@ class UINodes { var t = Reflect.copy(App.theme); t.ELEMENT_H = 18; t.BUTTON_H = 16; - var scale = armory.data.Config.raw.window_scale; + var scale = Config.raw.window_scale; ui = new Zui({font: App.font, theme: t, color_wheel: App.color_wheel, scaleFactor: scale}); ui.scrollEnabled = false; }); diff --git a/Sources/arm/ui/UIView2D.hx b/Sources/arm/ui/UIView2D.hx index 78178f69..7cbcbdf8 100644 --- a/Sources/arm/ui/UIView2D.hx +++ b/Sources/arm/ui/UIView2D.hx @@ -52,7 +52,7 @@ class UIView2D { var t = Reflect.copy(App.theme); t.ELEMENT_H = 18; t.BUTTON_H = 16; - var scale = armory.data.Config.raw.window_scale; + var scale = Config.raw.window_scale; ui = new Zui({font: App.font, theme: t, color_wheel: App.color_wheel, scaleFactor: scale}); ui.scrollEnabled = false;