diff --git a/examples/utilities/tools/render/AO.qml b/examples/utilities/tools/render/AO.qml deleted file mode 100644 index fb2126befd..0000000000 --- a/examples/utilities/tools/render/AO.qml +++ /dev/null @@ -1,102 +0,0 @@ -// -// AO.qml -// examples/utilities/tools/render -// -// Created by Zach Pomerantz on 2/8/2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Item { - width: 200 - height: 200 - property QtObject config: Render.getConfig("AmbientOcclusion") - - // TODO: Enable the gpuTimer when it is fixed in cpp - // Timer { - // interval: 500 - // running: true - // repeat: true - // onTriggered: { parent.timer.text = config.gpuTime.toFixed(2) } - // } - // Label { id: timer; x: 140 } - - Label { text: qsTr("Ambient Occlusion") } - - CheckBox { - y: 1 * 25 - text: qsTr("Dithering") - partiallyCheckedEnabled: false - checked: parent.config.ditheringEnabled - onCheckedChanged: { parent.config.ditheringEnabled = checked } - } - - ConfigSlider { - y: 2 * 25 - config: parent.config - prop: "resolutionLevel" - label: qsTr("Resolution Level") - min: 0; max: 4 - } - ConfigSlider { - y: 3 * 25 - config: parent.config - prop: "obscuranceLevel" - label: qsTr("Obscurance Level") - min: 0; max: 1 - } - ConfigSlider { - y: 4 * 25 - config: parent.config - prop: "radius" - label: qsTr("Radius") - min: 0; max: 2 - } - ConfigSlider { - y: 5 * 25 - config: parent.config - prop: "numSamples" - label: qsTr("Samples") - min: 0; max: 32 - } - ConfigSlider { - y: 6 * 25 - config: parent.config - prop: "numSpiralTurns" - label: qsTr("Spiral Turns") - min: 0; max: 30 - } - ConfigSlider { - y: 7 * 25 - config: parent.config - prop: "falloffBias" - label: qsTr("Falloff Bias") - min: 0; max: 0.2 - } - ConfigSlider { - y: 8 * 25 - config: parent.config - prop: "edgeSharpness" - label: qsTr("Edge Sharpness") - min: 0; max: 1 - } - ConfigSlider { - y: 9 * 25 - config: parent.config - prop: "blurRadius" - label: qsTr("Blur Radius") - min: 0; max: 6 - } - ConfigSlider { - y: 10 * 25 - config: parent.config - prop: "blurDeviation" - label: qsTr("Blur Deviation") - min: 0; max: 3 - } -} - diff --git a/examples/utilities/tools/render/Buffer.qml b/examples/utilities/tools/render/Buffer.qml deleted file mode 100644 index bc4b654257..0000000000 --- a/examples/utilities/tools/render/Buffer.qml +++ /dev/null @@ -1,99 +0,0 @@ -// -// Buffer.qml -// examples/utilities/tools/render -// -// Created by Zach Pomerantz on 2/8/2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Item { - width: 200 - height: 270 - - Label { - text: qsTr("Debug Buffer") - } - - ExclusiveGroup { id: buffer } - - function setDebugMode(mode) { - var debug = Render.getConfig("DebugDeferredBuffer"); - console.log(mode); - debug.enabled = (mode != 0); - debug.mode = mode; - } - - RadioButton { - x: 8; y: 19 + 0 * 23 - text: qsTr("Off") - exclusiveGroup: buffer - checked: true - onCheckedChanged: { if (checked) { setDebugMode(0) } } - } - RadioButton { - x: 8; y: 19 + 1 * 23 - text: qsTr("Diffuse") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(1) } } - } - RadioButton { - x: 8; y: 19 + 2 * 23 - text: qsTr("Metallic") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(2) } } - } - RadioButton { - x: 8; y: 19 + 3 * 23 - text: qsTr("Roughness") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(3) } } - } - RadioButton { - x: 8; y: 19 + 4 * 23 - text: qsTr("Normal") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(4) } } - } - RadioButton { - x: 8; y: 19 + 5 * 23 - text: qsTr("Depth") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(5) } } - } - RadioButton { - x: 8; y: 19 + 6 * 23 - text: qsTr("Lighting") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(6) } } - } - RadioButton { - x: 8; y: 19 + 7 * 23 - text: qsTr("Shadow") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(7) } } - } - RadioButton { - x: 8; y: 19 + 8 * 23 - text: qsTr("Pyramid Depth") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(8) } } - } - RadioButton { - x: 8; y: 19 + 9 * 23 - text: qsTr("Ambient Occlusion") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(9) } } - } - RadioButton { - x: 8; y: 19 + 10 * 23 - text: qsTr("Custom Shader") - exclusiveGroup: buffer - onCheckedChanged: { if (checked) { setDebugMode(10) } } - } -} - diff --git a/examples/utilities/tools/render/ConfigSlider.qml b/examples/utilities/tools/render/ConfigSlider.qml index 7c6498a7d2..5ee62dfe49 100644 --- a/examples/utilities/tools/render/ConfigSlider.qml +++ b/examples/utilities/tools/render/ConfigSlider.qml @@ -12,47 +12,55 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 Item { + id: root width: 400 height: 24 - property string label - property QtObject config - property string prop - property real min: 0.0 - property real max: 1.0 + property bool integral: false + property var config + property string property + property alias label: labelControl.text + property alias min: sliderControl.minimumValue + property alias max: sliderControl.maximumValue - function init() { - stat.text = config[prop].toFixed(2); - slider.value = (config[prop] - min) / (max - min); - } - Component.onCompleted: init() - - function update() { - var val = min + (max - min) * slider.value; - stat.text = val.toFixed(2); - config[prop] = val; + Component.onCompleted: { + // Binding favors qml value, so set it first + sliderControl.value = root.config[root.property]; + bindingControl.when = true; } Label { - text: parent.label - y: 7 - anchors.left: parent.left + id: labelControl + text: root.label + anchors.left: root.left anchors.leftMargin: 8 + anchors.top: root.top + anchors.topMargin: 7 } Label { - id: stat - y: 7 - anchors.left: parent.left + text: sliderControl.value.toFixed(root.integral ? 0 : 2) + anchors.left: root.left anchors.leftMargin: 140 + anchors.top: root.top + anchors.topMargin: 7 + } + + Binding { + id: bindingControl + target: root.config + property: root.property + value: sliderControl.value + when: false } Slider { - id: slider - y: 3 + id: sliderControl + stepSize: root.integral ? 1.0 : 0.0 width: 192 height: 20 - onValueChanged: parent.update() - anchors.right: parent.right + anchors.right: root.right anchors.rightMargin: 8 + anchors.top: root.top + anchors.topMargin: 3 } } diff --git a/examples/utilities/tools/render/ItemsSlider.qml b/examples/utilities/tools/render/ItemsSlider.qml deleted file mode 100644 index 1623284579..0000000000 --- a/examples/utilities/tools/render/ItemsSlider.qml +++ /dev/null @@ -1,59 +0,0 @@ -// -// ItemsSlider.qml -// examples/utilities/tools/render -// -// Created by Zach Pomerantz on 2/8/2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Item { - width: 400 - height: 24 - property string label - property QtObject config - - function update() { - var val = slider.value; - var max = config.numDrawn; - var drawn = Math.round(val * max); - stat.text = drawn + " / " + max; - config.maxDrawn = (val == 1.0 ? -1 : drawn); - } - - Timer { - interval: 500 - running: true - repeat: true - onTriggered: parent.update() - } - - Label { - text: parent.label - y: 7 - anchors.left: parent.left - anchors.leftMargin: 8 - } - - Label { - id: stat - y: 7 - anchors.left: parent.left - anchors.leftMargin: 108 - } - - Slider { - id: slider - y: 3 - width: 192 - height: 20 - value: 1.0 - onValueChanged: update() - anchors.right: parent.right - anchors.rightMargin: 8 - } -} diff --git a/examples/utilities/tools/render/Tone.qml b/examples/utilities/tools/render/Tone.qml deleted file mode 100644 index a0eb4b1e00..0000000000 --- a/examples/utilities/tools/render/Tone.qml +++ /dev/null @@ -1,49 +0,0 @@ -// -// Tone.qml -// examples/utilities/tools/render -// -// Created by Zach Pomerantz on 2/8/2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -Item { - width: 400 - height: 24 - property string label: qsTr("Tone Mapping Exposure") - - function update() { - var val = (slider.value - 0.5) * 20; - stat.text = val.toFixed(2); - Render.getConfig("ToneMapping").exposure = val; - } - - Label { - text: parent.label - y: 7 - anchors.left: parent.left - anchors.leftMargin: 8 - } - - Label { - id: stat - y: 7 - anchors.left: parent.left - anchors.leftMargin: 150 - } - - Slider { - id: slider - y: 3 - width: 192 - height: 20 - value: Render.getConfig("ToneMapping").exposure - onValueChanged: parent.update() - anchors.right: parent.right - anchors.rightMargin: 8 - } -} diff --git a/examples/utilities/tools/render/debug.js b/examples/utilities/tools/render/debug.js index 896d2ac179..f195c607a4 100644 --- a/examples/utilities/tools/render/debug.js +++ b/examples/utilities/tools/render/debug.js @@ -11,8 +11,12 @@ oldConfig = Render.toJSON(); Render.RenderShadowTask.enabled = true; -Render.RenderDeferredTask.AmbientOcclusion.enabled = true; -Render.RenderDeferredTask.DebugDeferredBuffer.enabled = false; +var RDT = Render.RenderDeferredTask; +RDT.AmbientOcclusion.enabled = true; +RDT.DebugDeferredBuffer.enabled = false; +["DrawOpaqueDeferred", "DrawTransparentDeferred", "DrawOverlay3DOpaque", "DrawOverlay3DTransparent"] + .map(function(name) { return RDT[name]; }) + .forEach(function(job) { job.maxDrawn = job.numDrawn; }); // Set up the qml ui var qml = Script.resolvePath('main.qml'); diff --git a/examples/utilities/tools/render/main.qml b/examples/utilities/tools/render/main.qml index 729e91c4f8..9e825ad4df 100644 --- a/examples/utilities/tools/render/main.qml +++ b/examples/utilities/tools/render/main.qml @@ -11,54 +11,100 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 -Item { - // Items - ItemsSlider { - y: 0 * 25 - label: qsTr("Opaque") - config: Render.getConfig("DrawOpaqueDeferred") - } - ItemsSlider { - y: 1 * 25 - label: qsTr("Transparent") - config: Render.getConfig("DrawTransparentDeferred") - } - ItemsSlider { - y: 2 * 25 - label: qsTr("Overlay3D") - config: Render.getConfig("DrawOverlay3D") +Column { + spacing: 8 + + Repeater { + model: [ "Opaque:DrawOpaqueDeferred", "Transparent:DrawTransparentDeferred", + "Opaque Overlays:DrawOverlay3DOpaque", "Transparent Overlays:DrawOverlay3DTransparent" ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: true + config: Render.getConfig(modelData.split(":")[1]) + property: "maxDrawn" + max: config.numDrawn + } } - // Draw status - Item { - y: 100 - + Row { CheckBox { text: qsTr("Display Status") - partiallyCheckedEnabled: false onCheckedChanged: { Render.getConfig("DrawStatus").showDisplay = checked } } CheckBox { - x: 200 text: qsTr("Network/Physics Status") - partiallyCheckedEnabled: false onCheckedChanged: { Render.getConfig("DrawStatus").showNetwork = checked } } } - // Tone mapping ConfigSlider { - y: 125 - config: Render.getConfig("ToneMapping") - prop: "exposure" label: qsTr("Tone Mapping Exposure") + config: Render.getConfig("ToneMapping") + property: "exposure" min: -10; max: 10 } - // Ambient occlusion - AO { y: 175 } + Column { + id: ambientOcclusion + property var config: Render.getConfig("AmbientOcclusion") - // Debug buffer - Buffer { y: 475 } + Label { text: qsTr("Ambient Occlusion") } + // TODO: Add gpuTimer + CheckBox { text: qsTr("Dithering"); checked: ambientOcclusion.config.ditheringEnabled } + Repeater { + model: [ + "Resolution Level:resolutionLevel:4", + "Obscurance Level:obscuranceLevel:1", + "Radius:radius:2", + "Falloff Bias:falloffBias:0.2", + "Edge Sharpness:edgeSharpness:1", + "Blur Radius:blurRadius:6", + "Blur Deviation:blurDeviation:3" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + config: ambientOcclusion.config + property: modelData.split(":")[1] + max: modelData.split(":")[2] + } + } + Repeater { + model: [ + "Samples:numSamples:32", + "Spiral Turns:numSpiralTurns:30:" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: true + config: ambientOcclusion.config + property: modelData.split(":")[1] + max: modelData.split(":")[2] + } + } + } + + Column { + id: debug + property var config: Render.getConfig("DebugDeferredBuffer") + + function setDebugMode(mode) { + debug.config.enabled = (mode != 0); + debug.config.mode = mode; + } + + Label { text: qsTr("Debug Buffer") } + ExclusiveGroup { id: bufferGroup } + Repeater { + model: [ + "Off", "Diffuse", "Metallic", "Roughness", "Normal", "Depth", + "Lighting", "Shadow", "Pyramid Depth", "Ambient Occlusion", "Custom Shader" + ] + RadioButton { + text: qsTr(modelData) + exclusiveGroup: bufferGroup + checked: index == 0 + onCheckedChanged: if (checked) debug.setDebugMode(index); + } + } + } } - diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index d3aeb23a50..30a49f93d5 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -142,7 +142,8 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont batch.setStateScissorRect(args->_viewport); args->_batch = &batch; - config->numDrawn = (int)inItems.size(); + config->setNumDrawn((int)inItems.size()); + emit config->numDrawnChanged(); glm::mat4 projMat; Transform viewMat; @@ -179,7 +180,8 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon inItems.emplace_back(id); } } - config->numItems = (int)inItems.size(); + config->setNumDrawn((int)inItems.size()); + emit config->numDrawnChanged(); if (!inItems.empty()) { RenderArgs* args = renderContext->args; diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 5d97de3905..3d072bce7b 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -40,15 +40,20 @@ public: class DrawConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(int numDrawn READ getNumDrawn) + Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) public: int getNumDrawn() { return numDrawn; } + void setNumDrawn(int num) { numDrawn = num; emit numDrawnChanged(); } - int numDrawn{ 0 }; int maxDrawn{ -1 }; + signals: + void numDrawnChanged(); void dirty(); + +protected: + int numDrawn{ 0 }; }; class DrawDeferred { @@ -86,15 +91,20 @@ public: class DrawOverlay3DConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(int numItems READ getNumItems) + Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) public: - int getNumItems() { return numItems; } + int getNumDrawn() { return numDrawn; } + void setNumDrawn(int num) { numDrawn = num; emit numDrawnChanged(); } - int numItems{ 0 }; int maxDrawn{ -1 }; + signals: + void numDrawnChanged(); void dirty(); + +protected: + int numDrawn{ 0 }; }; class DrawOverlay3D {