Improvement of debug shadow script

This commit is contained in:
Olivier Prat 2018-08-03 18:01:22 +02:00
parent 0c8d8e985f
commit f2a01021f3
8 changed files with 214 additions and 126 deletions

View file

@ -205,7 +205,9 @@ void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inp
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1);
assert(items.canCast<RenderFetchCullSortTask::Output>());
if (isDeferred) {
task.addJob<RenderDeferredTask>("RenderDeferredTask", items, false);
const render::Varying cascadeSceneBBoxes;
const auto renderInput = RenderDeferredTask::Input(items, cascadeSceneBBoxes).asVarying();
task.addJob<RenderDeferredTask>("RenderDeferredTask", renderInput, false);
} else {
task.addJob<RenderForwardTask>("Forward", items);
}

View file

@ -83,7 +83,9 @@ const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, cons
}
void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, bool renderShadows) {
const auto& items = input.get<Input>();
const auto& inputs = input.get<Input>();
const auto& items = inputs.get0();
auto fadeEffect = DependencyManager::get<FadeEffect>();
// Prepare the ShapePipelines
@ -246,11 +248,17 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto viewFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::VIEW_FRUSTUM);
task.addJob<DrawFrustum>("DrawViewFrustum", viewFrustum, glm::vec3(1.0f, 1.0f, 0.0f));
for (auto i = 0; i < ExtractFrustums::SHADOW_CASCADE_FRUSTUM_COUNT; i++) {
const auto shadowFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::SHADOW_CASCADE0_FRUSTUM+i);
const auto shadowFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::SHADOW_CASCADE0_FRUSTUM + i);
float tint = 1.0f - i / float(ExtractFrustums::SHADOW_CASCADE_FRUSTUM_COUNT - 1);
char jobName[64];
sprintf(jobName, "DrawShadowFrustum%d", i);
task.addJob<DrawFrustum>(jobName, shadowFrustum, glm::vec3(0.0f, tint, 1.0f));
if (!inputs[1].isNull()) {
const auto& shadowCascadeSceneBBoxes = inputs.get1();
const auto shadowBBox = shadowCascadeSceneBBoxes[ExtractFrustums::SHADOW_CASCADE0_FRUSTUM + i];
sprintf(jobName, "DrawShadowBBox%d", i);
task.addJob<DrawAABox>(jobName, shadowBBox, glm::vec3(1.0f, tint, 0.0f));
}
}
// Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true

View file

@ -16,6 +16,7 @@
#include <render/RenderFetchCullSortTask.h>
#include "LightingModel.h"
#include "LightClusters.h"
#include "RenderShadowTask.h"
class DrawDeferredConfig : public render::Job::Config {
Q_OBJECT
@ -135,7 +136,7 @@ signals:
class RenderDeferredTask {
public:
using Input = RenderFetchCullSortTask::Output;
using Input = render::VaryingSet2<RenderFetchCullSortTask::Output, RenderShadowTask::Output>;
using Config = RenderDeferredTaskConfig;
using JobModel = render::Task::ModelI<RenderDeferredTask, Input, Config>;

View file

@ -260,6 +260,8 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
#endif
};
Output cascadeSceneBBoxes;
for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) {
char jobName[64];
sprintf(jobName, "ShadowCascadeSetup%d", i);
@ -279,8 +281,12 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
sprintf(jobName, "RenderShadowMap%d", i);
task.addJob<RenderShadowMap>(jobName, culledShadowItemsAndBounds, shapePlumber, i);
task.addJob<RenderShadowCascadeTeardown>("ShadowCascadeTeardown", shadowFilter);
cascadeSceneBBoxes[i] = culledShadowItemsAndBounds.getN<CullShadowBounds::Outputs>(1);
}
output = render::Varying(cascadeSceneBBoxes);
task.addJob<RenderShadowTeardown>("ShadowTeardown", setupOutput);
}

View file

@ -46,8 +46,11 @@ signals:
class RenderShadowTask {
public:
// There is one AABox per shadow cascade
using Output = render::VaryingArray<AABox, SHADOW_CASCADE_MAX_COUNT>;
using Config = RenderShadowTaskConfig;
using JobModel = render::Task::Model<RenderShadowTask, Config>;
using JobModel = render::Task::ModelO<RenderShadowTask, Output, Config>;
RenderShadowTask() {}
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cameraCullFunctor, uint8_t tagBits = 0x00, uint8_t tagMask = 0x00);

View file

@ -17,17 +17,15 @@
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, bool isDeferred, uint8_t tagBits, uint8_t tagMask) {
// auto items = input.get<Input>();
// Warning : the cull functor passed to the shadow pass should only be testing for LOD culling. If frustum culling
// is performed, then casters not in the view frustum will be removed, which is not what we wish.
if (isDeferred) {
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor, tagBits, tagMask);
}
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, tagBits, tagMask);
assert(items.canCast<RenderFetchCullSortTask::Output>());
if (isDeferred) {
task.addJob<RenderDeferredTask>("RenderDeferredTask", items, true);
// Warning : the cull functor passed to the shadow pass should only be testing for LOD culling. If frustum culling
// is performed, then casters not in the view frustum will be removed, which is not what we wish.
const auto cascadeSceneBBoxes = task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor, tagBits, tagMask);
const auto renderInput = RenderDeferredTask::Input(items, cascadeSceneBBoxes).asVarying();
task.addJob<RenderDeferredTask>("RenderDeferredTask", renderInput, true);
} else {
task.addJob<RenderForwardTask>("Forward", items);
}

View file

@ -1,3 +1,5 @@
"use strict";
//
// debugShadow.js
// developer/utilities/render
@ -9,12 +11,71 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// Set up the qml ui
var qml = Script.resolvePath('shadow.qml');
var window = new OverlayWindow({
title: 'Shadow Debug',
source: qml,
width: 250,
height: 300
});
window.closed.connect(function() { Script.stop(); });
(function() {
var TABLET_BUTTON_NAME = "Shadow";
var QMLAPP_URL = Script.resolvePath("./shadow.qml");
var onLuciScreen = false;
function onClicked() {
if (onLuciScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
sortOrder: 1
});
var hasEventBridge = false;
function wireEventBridge(on) {
if (!tablet) {
print("Warning in wireEventBridge(): 'tablet' undefined!");
return;
}
if (on) {
if (!hasEventBridge) {
tablet.fromQml.connect(fromQml);
hasEventBridge = true;
}
} else {
if (hasEventBridge) {
tablet.fromQml.disconnect(fromQml);
hasEventBridge = false;
}
}
}
function onScreenChanged(type, url) {
if (url === QMLAPP_URL) {
onLuciScreen = true;
} else {
onLuciScreen = false;
}
button.editProperties({isActive: onLuciScreen});
wireEventBridge(onLuciScreen);
}
function fromQml(message) {
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
Script.scriptEnding.connect(function () {
if (onLuciScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
});
}());

View file

@ -8,21 +8,31 @@
// 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 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import "qrc:///qml/styles-uit"
import "qrc:///qml/controls-uit" as HifiControls
import "configSlider"
import "configSlider"
Rectangle {
id: root;
HifiConstants { id: hifi; }
color: hifi.colors.baseGray;
Column {
id: root
spacing: 8
property var viewConfig: Render.getConfig("RenderMainView.DrawViewFrustum");
property var shadowConfig : Render.getConfig("RenderMainView.ShadowSetup");
property var shadow0Config: Render.getConfig("RenderMainView.DrawShadowFrustum0");
property var shadow1Config: Render.getConfig("RenderMainView.DrawShadowFrustum1");
property var shadow2Config: Render.getConfig("RenderMainView.DrawShadowFrustum2");
property var shadow3Config: Render.getConfig("RenderMainView.DrawShadowFrustum3");
property var shadowBBox0Config: Render.getConfig("RenderMainView.DrawShadowBBox0");
property var shadowBBox1Config: Render.getConfig("RenderMainView.DrawShadowBBox1");
property var shadowBBox2Config: Render.getConfig("RenderMainView.DrawShadowBBox2");
property var shadowBBox3Config: Render.getConfig("RenderMainView.DrawShadowBBox3");
Component.onCompleted: {
viewConfig.enabled = true;
@ -30,6 +40,10 @@ Column {
shadow1Config.enabled = true;
shadow2Config.enabled = true;
shadow3Config.enabled = true;
shadowBBox0Config.enabled = true;
shadowBBox1Config.enabled = true;
shadowBBox2Config.enabled = true;
shadowBBox3Config.enabled = true;
}
Component.onDestruction: {
viewConfig.enabled = false;
@ -41,108 +55,103 @@ Column {
shadow1Config.isFrozen = false;
shadow2Config.isFrozen = false;
shadow3Config.isFrozen = false;
shadow0BoundConfig.isFrozen = false;
shadow1BoundConfig.isFrozen = false;
shadow2BoundConfig.isFrozen = false;
shadow3BoundConfig.isFrozen = false;
shadowBBox0Config.enabled = false;
shadowBBox1Config.enabled = false;
shadowBBox2Config.enabled = false;
shadowBBox3Config.enabled = false;
shadowBBox0Config.isFrozen = false;
shadowBBox1Config.isFrozen = false;
shadowBBox2Config.isFrozen = false;
shadowBBox3Config.isFrozen = false;
}
CheckBox {
text: "Freeze Frustums"
checked: false
onCheckedChanged: {
viewConfig.isFrozen = checked;
shadow0Config.isFrozen = checked;
shadow1Config.isFrozen = checked;
shadow2Config.isFrozen = checked;
shadow3Config.isFrozen = checked;
shadow0BoundConfig.isFrozen = checked;
shadow1BoundConfig.isFrozen = checked;
shadow2BoundConfig.isFrozen = checked;
shadow3BoundConfig.isFrozen = checked;
}
}
Row {
spacing: 8
Label {
text: "View"
color: "yellow"
font.italic: true
}
Label {
text: "Shadow"
color: "blue"
font.italic: true
}
Label {
text: "Items"
color: "magenta"
font.italic: true
}
}
ConfigSlider {
label: qsTr("Cascade 0 constant bias")
integral: false
config: shadowConfig
property: "constantBias0"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 1 constant bias")
integral: false
config: shadowConfig
property: "constantBias1"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 2 constant bias")
integral: false
config: shadowConfig
property: "constantBias2"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 3 constant bias")
integral: false
config: shadowConfig
property: "constantBias3"
max: 1.0
min: 0.0
}
ColumnLayout {
spacing: 20
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: hifi.dimensions.contentMargin.x
ConfigSlider {
label: qsTr("Cascade 0 slope bias")
integral: false
config: shadowConfig
property: "slopeBias0"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 1 slope bias")
integral: false
config: shadowConfig
property: "slopeBias1"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 2 slope bias")
integral: false
config: shadowConfig
property: "slopeBias2"
max: 1.0
min: 0.0
}
ConfigSlider {
label: qsTr("Cascade 3 slope bias")
integral: false
config: shadowConfig
property: "slopeBias3"
max: 1.0
min: 0.0
RowLayout {
spacing: 20
Layout.fillWidth: true
HifiControls.CheckBox {
boxSize: 20
text: "Freeze"
checked: false
onCheckedChanged: {
viewConfig.isFrozen = checked;
shadow0Config.isFrozen = checked;
shadow1Config.isFrozen = checked;
shadow2Config.isFrozen = checked;
shadow3Config.isFrozen = checked;
shadowBBox0Config.isFrozen = checked;
shadowBBox1Config.isFrozen = checked;
shadowBBox2Config.isFrozen = checked;
shadowBBox3Config.isFrozen = checked;
}
}
HifiControls.Label {
text: "View"
color: "yellow"
font.italic: true
}
HifiControls.Label {
text: "Shadow"
color: "blue"
font.italic: true
}
HifiControls.Label {
text: "AABB"
color: "red"
font.italic: true
}
}
Repeater {
model: [
"0", "1", "2", "3"
]
ColumnLayout {
spacing: 8
anchors.left: parent.left
anchors.right: parent.right
HifiControls.Separator {
anchors.left: parent.left
anchors.right: parent.right
}
HifiControls.CheckBox {
text: "Cascade "+modelData
boxSize: 20
checked: Render.getConfig("RenderMainView.DrawShadowFrustum"+modelData)
onCheckedChanged: {
Render.getConfig("RenderMainView.DrawShadowFrustum"+modelData).enabled = checked;
Render.getConfig("RenderMainView.DrawShadowBBox"+modelData).enabled = checked;
}
}
ConfigSlider {
label: qsTr("Constant bias")
integral: false
config: shadowConfig
property: "constantBias"+modelData
max: 1.0
min: 0.0
height: 38
width:250
}
ConfigSlider {
label: qsTr("Slope bias")
integral: false
config: shadowConfig
property: "slopeBias"+modelData
max: 1.0
min: 0.0
height: 38
width: 250
}
}
}
}
}