diff --git a/Shaders/deferred_indirect/deferred_indirect.frag.glsl b/Shaders/deferred_indirect/deferred_indirect.frag.glsl index af274c68..3af2811b 100644 --- a/Shaders/deferred_indirect/deferred_indirect.frag.glsl +++ b/Shaders/deferred_indirect/deferred_indirect.frag.glsl @@ -11,22 +11,13 @@ precision mediump float; #include "../std/math.glsl" // envMapEquirect() #include "../std/brdf.glsl" -// ... -#ifdef _Probes - #include "../std/shirr_probe.glsl" -#else - #include "../std/shirr.glsl" -#endif +#include "../std/shirr.glsl" uniform sampler2D gbufferD; uniform sampler2D gbuffer0; uniform sampler2D gbuffer1; -#ifdef _Probes - //!uniform float shirr[27 * 6]; // Maximum of 6 SH sets -#else - //!uniform float shirr[27]; -#endif +//!uniform float shirr[27]; uniform float envmapStrength; #ifdef _Rad uniform sampler2D senvmapRadiance; @@ -66,37 +57,11 @@ void main() { #endif // Indirect -#ifdef _Probes - float probeFactor = g0.a; // mask_probe - float probeID = floor(probeFactor); - float probeFract = fract(probeFactor); - vec3 indirect; - #ifdef _Rad - float lod = getMipFromRoughness(metrough.y, envmapNumMipmaps); - vec3 reflectionWorld = reflect(-v, n); - vec2 envCoordRefl = envMapEquirect(reflectionWorld); - vec3 prefilteredColor = textureLod(senvmapRadiance, envCoordRefl, lod).rgb; - #endif - - // Global probe only - if (probeID == 0.0) { - indirect = shIrradiance(n, 2.2, 0) / PI; - } - // fract 0 = local probe, 1 = global probe - else { - indirect = (shIrradiance(n, 2.2, int(probeID)) / PI) * (1.0 - probeFract); - //prefilteredColor /= 4.0; - if (probeFract > 0.0) { - indirect += (shIrradiance(n, 2.2, 0) / PI) * (probeFract); - } - } -#else // No probes vec3 indirect = shIrradiance(n, 2.2) / PI; - #ifdef _Rad - vec3 reflectionWorld = reflect(-v, n); - float lod = getMipFromRoughness(metrough.y, envmapNumMipmaps); - vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb; - #endif +#ifdef _Rad + vec3 reflectionWorld = reflect(-v, n); + float lod = getMipFromRoughness(metrough.y, envmapNumMipmaps); + vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb; #endif #ifdef _EnvLDR diff --git a/Shaders/std/shirr_probe.glsl b/Shaders/std/shirr_probe.glsl deleted file mode 100755 index f2d39611..00000000 --- a/Shaders/std/shirr_probe.glsl +++ /dev/null @@ -1,68 +0,0 @@ -uniform float shirr[27 * 6]; // Maximum of 6 SH sets - -vec3 shIrradiance(vec3 nor, float scale, int probe) { - const float c1 = 0.429043; - const float c2 = 0.511664; - const float c3 = 0.743125; - const float c4 = 0.886227; - const float c5 = 0.247708; - vec3 cl00, cl1m1, cl10, cl11, cl2m2, cl2m1, cl20, cl21, cl22; - if (probe == 0) { - cl00 = vec3(shirr[0], shirr[1], shirr[2]); - cl1m1 = vec3(shirr[3], shirr[4], shirr[5]); - cl10 = vec3(shirr[6], shirr[7], shirr[8]); - cl11 = vec3(shirr[9], shirr[10], shirr[11]); - cl2m2 = vec3(shirr[12], shirr[13], shirr[14]); - cl2m1 = vec3(shirr[15], shirr[16], shirr[17]); - cl20 = vec3(shirr[18], shirr[19], shirr[20]); - cl21 = vec3(shirr[21], shirr[22], shirr[23]); - cl22 = vec3(shirr[24], shirr[25], shirr[26]); - } - else if (probe == 1) { - cl00 = vec3(shirr[27 + 0], shirr[27 + 1], shirr[27 + 2]); cl1m1 = vec3(shirr[27 + 3], shirr[27 + 4], shirr[27 + 5]); - cl10 = vec3(shirr[27 + 6], shirr[27 + 7], shirr[27 + 8]); cl11 = vec3(shirr[27 + 9], shirr[27 + 10], shirr[27 + 11]); - cl2m2 = vec3(shirr[27 + 12], shirr[27 + 13], shirr[27 + 14]); cl2m1 = vec3(shirr[27 + 15], shirr[27 + 16], shirr[27 + 17]); - cl20 = vec3(shirr[27 + 18], shirr[27 + 19], shirr[27 + 20]); cl21 = vec3(shirr[27 + 21], shirr[27 + 22], shirr[27 + 23]); - cl22 = vec3(shirr[27 + 24], shirr[27 + 25], shirr[27 + 26]); - } - else if (probe == 2) { - cl00 = vec3(shirr[27 * 2 + 0], shirr[27 * 2 + 1], shirr[27 * 2 + 2]); cl1m1 = vec3(shirr[27 * 2 + 3], shirr[27 * 2 + 4], shirr[27 * 2 + 5]); - cl10 = vec3(shirr[27 * 2 + 6], shirr[27 * 2 + 7], shirr[27 * 2 + 8]); cl11 = vec3(shirr[27 * 2 + 9], shirr[27 * 2 + 10], shirr[27 * 2 + 11]); - cl2m2 = vec3(shirr[27 * 2 + 12], shirr[27 * 2 + 13], shirr[27 * 2 + 14]); cl2m1 = vec3(shirr[27 * 2 + 15], shirr[27 * 2 + 16], shirr[27 * 2 + 17]); - cl20 = vec3(shirr[27 * 2 + 18], shirr[27 * 2 + 19], shirr[27 * 2 + 20]); cl21 = vec3(shirr[27 * 2 + 21], shirr[27 * 2 + 22], shirr[27 * 2 + 23]); - cl22 = vec3(shirr[27 * 2 + 24], shirr[27 * 2 + 25], shirr[27 * 2 + 26]); - } - else if (probe == 3) { - cl00 = vec3(shirr[27 * 3 + 0], shirr[27 * 3 + 1], shirr[27 * 3 + 2]); cl1m1 = vec3(shirr[27 * 3 + 3], shirr[27 * 3 + 4], shirr[27 * 3 + 5]); - cl10 = vec3(shirr[27 * 3 + 6], shirr[27 * 3 + 7], shirr[27 * 3 + 8]); cl11 = vec3(shirr[27 * 3 + 9], shirr[27 * 3 + 10], shirr[27 * 3 + 11]); - cl2m2 = vec3(shirr[27 * 3 + 12], shirr[27 * 3 + 13], shirr[27 * 3 + 14]); cl2m1 = vec3(shirr[27 * 3 + 15], shirr[27 * 3 + 16], shirr[27 * 3 + 17]); - cl20 = vec3(shirr[27 * 3 + 18], shirr[27 * 3 + 19], shirr[27 * 3 + 20]); cl21 = vec3(shirr[27 * 3 + 21], shirr[27 * 3 + 22], shirr[27 * 3 + 23]); - cl22 = vec3(shirr[27 * 3 + 24], shirr[27 * 3 + 25], shirr[27 * 3 + 26]); - } - else if (probe == 4) { - cl00 = vec3(shirr[27 * 4 + 0], shirr[27 * 4 + 1], shirr[27 * 4 + 2]); cl1m1 = vec3(shirr[27 * 4 + 3], shirr[27 * 4 + 4], shirr[27 * 4 + 5]); - cl10 = vec3(shirr[27 * 4 + 6], shirr[27 * 4 + 7], shirr[27 * 4 + 8]); cl11 = vec3(shirr[27 * 4 + 9], shirr[27 * 4 + 10], shirr[27 * 4 + 11]); - cl2m2 = vec3(shirr[27 * 4 + 12], shirr[27 * 4 + 13], shirr[27 * 4 + 14]); cl2m1 = vec3(shirr[27 * 4 + 15], shirr[27 * 4 + 16], shirr[27 * 4 + 17]); - cl20 = vec3(shirr[27 * 4 + 18], shirr[27 * 4 + 19], shirr[27 * 4 + 20]); cl21 = vec3(shirr[27 * 4 + 21], shirr[27 * 4 + 22], shirr[27 * 4 + 23]); - cl22 = vec3(shirr[27 * 4 + 24], shirr[27 * 4 + 25], shirr[27 * 4 + 26]); - } - else if (probe == 5) { - cl00 = vec3(shirr[27 * 5 + 0], shirr[27 * 5 + 1], shirr[27 * 5 + 2]); cl1m1 = vec3(shirr[27 * 5 + 3], shirr[27 * 5 + 4], shirr[27 * 5 + 5]); - cl10 = vec3(shirr[27 * 5 + 6], shirr[27 * 5 + 7], shirr[27 * 5 + 8]); cl11 = vec3(shirr[27 * 5 + 9], shirr[27 * 5 + 10], shirr[27 * 5 + 11]); - cl2m2 = vec3(shirr[27 * 5 + 12], shirr[27 * 5 + 13], shirr[27 * 5 + 14]); cl2m1 = vec3(shirr[27 * 5 + 15], shirr[27 * 5 + 16], shirr[27 * 5 + 17]); - cl20 = vec3(shirr[27 * 5 + 18], shirr[27 * 5 + 19], shirr[27 * 5 + 20]); cl21 = vec3(shirr[27 * 5 + 21], shirr[27 * 5 + 22], shirr[27 * 5 + 23]); - cl22 = vec3(shirr[27 * 5 + 24], shirr[27 * 5 + 25], shirr[27 * 5 + 26]); - } - return ( - c1 * cl22 * (nor.y * nor.y - (-nor.z) * (-nor.z)) + - c3 * cl20 * nor.x * nor.x + - c4 * cl00 - - c5 * cl20 + - 2.0 * c1 * cl2m2 * nor.y * (-nor.z) + - 2.0 * c1 * cl21 * nor.y * nor.x + - 2.0 * c1 * cl2m1 * (-nor.z) * nor.x + - 2.0 * c2 * cl11 * nor.y + - 2.0 * c2 * cl1m1 * (-nor.z) + - 2.0 * c2 * cl10 * nor.x - ) * scale; -} diff --git a/Sources/armory/trait/internal/Console.hx b/Sources/armory/trait/internal/Console.hx index b1cfda71..28cf04ff 100755 --- a/Sources/armory/trait/internal/Console.hx +++ b/Sources/armory/trait/internal/Console.hx @@ -6,8 +6,88 @@ import kha.Scheduler; import iron.data.RenderPath; import iron.object.CameraObject; import iron.object.MeshObject; -import zui.Zui; -import zui.Id; +import bui.Bui; +#end + +#if arm_profile +@:keep +class ProfilePanel extends Panel { + + var console:Console; + + public function new(console:Console) { + super(); + this.console = console; + label = "Profile (ms)"; + } + + public override function draw(layout:Layout) { + var avg = Math.round(console.frameTimeAvg * 10000) / 10; + var avgMin = Math.round(console.frameTimeAvgMin * 10000) / 10; + var avgMax = Math.round(console.frameTimeAvgMax * 10000) / 10; + layout.label('frame: $avg ($avgMin/$avgMax)'); + var gpuTime = console.frameTimeAvg - console.renderTimeAvg - console.updateTimeAvg; + if (gpuTime < console.renderTimeAvg) gpuTime = console.renderTimeAvg; + layout.label("gpu: " + Math.round(gpuTime * 10000) / 10); + layout.label("render: " + Math.round(console.renderTimeAvg * 10000) / 10); + layout.label("update: " + Math.round(console.updateTimeAvg * 10000) / 10); + layout.label(" phys: " + Math.round(console.physTimeAvg * 10000) / 10); + layout.label(" anim: 0.0"); + } +} + +@:keep +class PathPanel extends Panel { + + var console:Console; + + var passProps:Array = null; + + public function new(console:Console) { + super(); + this.console = console; + closed = true; + label = "Render Path"; + } + + public override function draw(layout:Layout) { + var path = console.path; + layout.label("draw calls: " + RenderPath.drawCalls); + layout.label("render targets: " + path.data.pathdata.raw.render_targets.length); + + for (i in 0...path.passNames.length) { + path.passEnabled[i] = layout._bool(path.passNames[i], path.passEnabled[i]); + } + } +} + +@:keep +class OutlinerPanel extends Panel { + + var console:Console; + + public function new(console:Console) { + super(); + this.console = console; + closed = true; + label = "Outliner"; + } + + public override function draw(layout:Layout) { + for (o in iron.Scene.active.meshes) { + o.visible = layout._bool(o.name, o.visible); + } + for (o in iron.Scene.active.lamps) { + o.visible = layout._bool(o.name, o.visible); + } + for (o in iron.Scene.active.cameras) { + o.visible = layout._bool(o.name, o.visible); + } + for (o in iron.Scene.active.speakers) { + o.visible = layout._bool(o.name, o.visible); + } + } +} #end @:keep @@ -17,33 +97,44 @@ class Console extends Trait { public function new() { super(); } #else - var ui:Zui; - var path:RenderPath; + var bui:Bui; + var area:Area; + + public var path:RenderPath; var lastTime = 0.0; var frameTime = 0.0; var totalTime = 0.0; var frames = 0; - var frameTimeAvg = 0.0; - var frameTimeAvgMin = 0.0; - var frameTimeAvgMax = 0.0; - var renderTime = 0.0; - var renderTimeAvg = 0.0; - var updateTime = 0.0; - var updateTimeAvg = 0.0; - var physTime = 0.0; - var physTimeAvg = 0.0; + public var frameTimeAvg = 0.0; + public var frameTimeAvgMin = 0.0; + public var frameTimeAvgMax = 0.0; + public var renderTime = 0.0; + public var renderTimeAvg = 0.0; + public var updateTime = 0.0; + public var updateTimeAvg = 0.0; + public var physTime = 0.0; + public var physTimeAvg = 0.0; public function new() { super(); - iron.data.Data.getFont('droid_sans.ttf', function(font:kha.Font) { - ui = new Zui(font, 17, 16, 0, 1.0, 2.0); + iron.data.Data.getFont('dejavu.ttf', function(font:kha.Font) { + iron.data.Data.getBlob('btheme.json', function(blob:kha.Blob) { + iron.data.Data.getImage('batlas.png', function(image:kha.Image) { + bui = new Bui(blob, image, font); + area = bui.addArea(0, 0, 160, iron.App.h()); + area.addPanel(new ProfilePanel(this)); + area.addPanel(new PathPanel(this)); + area.addPanel(new OutlinerPanel(this)); + notifyOnInit(init); notifyOnRender2D(render2D); notifyOnUpdate(update); }); + }); + }); } function init() { @@ -51,59 +142,14 @@ class Console extends Trait { } function render2D(g:kha.graphics2.Graphics) { - g.end(); - ui.begin(g); - if (ui.window(Id.window(), 0, 0, 250, iron.App.h())) { - if (ui.node(Id.node(), "Profile (ms)", 0, true)) { - var avg = Math.round(frameTimeAvg * 10000) / 10; - var avgMin = Math.round(frameTimeAvgMin * 10000) / 10; - var avgMax = Math.round(frameTimeAvgMax * 10000) / 10; - ui.text('frame: $avg ($avgMin/$avgMax)'); - var gpuTime = frameTimeAvg - renderTimeAvg - updateTimeAvg; - if (gpuTime < renderTimeAvg) gpuTime = renderTimeAvg; - ui.text("gpu: " + Math.round(gpuTime * 10000) / 10); - ui.text("render: " + Math.round(renderTimeAvg * 10000) / 10); - ui.text("update: " + Math.round(updateTimeAvg * 10000) / 10); - ui.indent(); - ui.text("phys: " + Math.round(physTimeAvg * 10000) / 10); - ui.text("anim: 0.0"); - ui.unindent(); - } - ui.separator(); - if (ui.node(Id.node(), "Render Path", 0, false)) { - ui.text("draw calls: " + RenderPath.drawCalls); - ui.text("render targets: " + path.data.pathdata.raw.render_targets.length); - for (i in 0...path.passNames.length) { - path.passEnabled[i] = ui.check(Id.nest(Id.check(), i), path.passNames[i], path.passEnabled[i]); - } - } - ui.separator(); - if (ui.node(Id.node(), "Inspector", 0, false)) { - - function drawList(id:String, objs:Array) { - for (i in 0...objs.length) { - var o = objs[i]; - var text = o.name + " (" + Std.int(o.transform.absx() * 100) / 100 + ", " + Std.int(o.transform.absy() * 100) / 100 + ", " + Std.int(o.transform.absz() * 100) / 100 + ")"; - if (Std.is(o, MeshObject)) text += " - " + Std.int(cast(o, MeshObject).screenSize * 100) / 100; - o.visible = ui.check(Id.nest(id, i), text, o.visible); - } - } - - drawList(Id.check(), cast iron.Scene.active.meshes); - drawList(Id.check(), cast iron.Scene.active.lamps); - drawList(Id.check(), cast iron.Scene.active.cameras); - drawList(Id.check(), cast iron.Scene.active.speakers); - } - } - ui.end(); - - g.begin(false); + bui.draw(g); #if arm_profile totalTime += frameTime; renderTime += iron.App.renderTime; frames++; if (totalTime > 1.0) { + area.tagRedraw(); var t = totalTime / frames; // Second frame if (frameTimeAvg > 0) { diff --git a/blender/props.py b/blender/props.py index 58b0b9f0..d8f57426 100755 --- a/blender/props.py +++ b/blender/props.py @@ -57,6 +57,7 @@ def init_properties(): items = [('Disabled', 'Disabled', 'Disabled'), ('Recast', 'Recast', 'Recast')], name = "Navigation", default='Recast') + bpy.types.World.arm_bui = BoolProperty(name="BUI", description="Include BUI library", default=False) bpy.types.World.arm_khafile = StringProperty(name = "Khafile", description="Source appended to khafile.js") bpy.types.World.arm_command_line = StringProperty(name = "Command Line", description="Commands appended to khamake") bpy.types.World.arm_minimize = BoolProperty(name="Minimize Data", description="Export scene data in binary", default=True, update=assets.invalidate_compiled_data) diff --git a/blender/props_ui.py b/blender/props_ui.py index 3b33eb3d..7f26a40d 100644 --- a/blender/props_ui.py +++ b/blender/props_ui.py @@ -397,6 +397,7 @@ class ArmoryBuildPanel(bpy.types.Panel): layout.label('Libraries') layout.prop(wrd, 'arm_physics') layout.prop(wrd, 'arm_navigation') + layout.prop(wrd, 'arm_bui') class ArmoryProjectPanel(bpy.types.Panel): bl_label = "Armory Project" diff --git a/blender/write_data.py b/blender/write_data.py index 1ffbd6fa..1b90913d 100755 --- a/blender/write_data.py +++ b/blender/write_data.py @@ -61,10 +61,15 @@ project.addSources('Sources'); if wrd.arm_play_console: f.write("project.addDefine('arm_profile');\n") - f.write(add_armory_library(sdk_path, 'lib/zui')) - font_path = sdk_path + '/armory/Assets/droid_sans.ttf' - font_path = font_path.replace('\\', '/') - f.write('project.addAssets("' + font_path + '");\n') + + if wrd.arm_play_console or wrd.arm_bui: + f.write(add_armory_library(sdk_path, 'lib/bui')) + p = sdk_path + '/lib/bui/Assets/dejavu.ttf' + f.write('project.addAssets("' + p.replace('\\', '/') + '");\n') + p = sdk_path + '/lib/bui/Assets/btheme.json' + f.write('project.addAssets("' + p.replace('\\', '/') + '");\n') + p = sdk_path + '/lib/bui/Assets/batlas.png' + f.write('project.addAssets("' + p.replace('\\', '/') + '");\n') # f.write(add_armory_library(sdk_path, 'lib/haxeui/haxeui-core')) # f.write(add_armory_library(sdk_path, 'lib/haxeui/haxeui-kha'))