mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 07:43:57 +02:00
Moving the scripts for render that where in utilities/tools/render to utilities/render, adding counters for lights
This commit is contained in:
parent
830d08c385
commit
be27eaff24
21 changed files with 211 additions and 119 deletions
1
examples/utilities/render/configSlider/qmldir
Normal file
1
examples/utilities/render/configSlider/qmldir
Normal file
|
@ -0,0 +1 @@
|
|||
ConfigSlider 1.0 ConfigSlider.qml
|
114
examples/utilities/render/culling.qml
Normal file
114
examples/utilities/render/culling.qml
Normal file
|
@ -0,0 +1,114 @@
|
|||
//
|
||||
// culling.qml
|
||||
// examples/utilities/render
|
||||
//
|
||||
// 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
|
||||
import "configSlider"
|
||||
|
||||
Column {
|
||||
id: root
|
||||
spacing: 8
|
||||
property var sceneOctree: Render.getConfig("DrawSceneOctree");
|
||||
property var itemSelection: Render.getConfig("DrawItemSelection");
|
||||
|
||||
Component.onCompleted: {
|
||||
sceneOctree.enabled = true;
|
||||
itemSelection.enabled = true;
|
||||
sceneOctree.showVisibleCells = false;
|
||||
sceneOctree.showEmptyCells = false;
|
||||
itemSelection.showInsideItems = false;
|
||||
itemSelection.showInsideSubcellItems = false;
|
||||
itemSelection.showPartialItems = false;
|
||||
itemSelection.showPartialSubcellItems = false;
|
||||
}
|
||||
Component.onDestruction: {
|
||||
sceneOctree.enabled = false;
|
||||
itemSelection.enabled = false;
|
||||
Render.getConfig("FetchSceneSelection").freezeFrustum = false;
|
||||
Render.getConfig("CullSceneSelection").freezeFrustum = false;
|
||||
}
|
||||
|
||||
GroupBox {
|
||||
title: "Culling"
|
||||
Row {
|
||||
spacing: 8
|
||||
Column {
|
||||
spacing: 8
|
||||
|
||||
CheckBox {
|
||||
text: "Freeze Culling Frustum"
|
||||
checked: false
|
||||
onCheckedChanged: {
|
||||
Render.getConfig("FetchSceneSelection").freezeFrustum = checked;
|
||||
Render.getConfig("CullSceneSelection").freezeFrustum = checked;
|
||||
}
|
||||
}
|
||||
Label {
|
||||
text: "Octree"
|
||||
}
|
||||
CheckBox {
|
||||
text: "Visible Cells"
|
||||
checked: root.sceneOctree.showVisibleCells
|
||||
onCheckedChanged: { root.sceneOctree.showVisibleCells = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Empty Cells"
|
||||
checked: false
|
||||
onCheckedChanged: { root.sceneOctree.showEmptyCells = checked }
|
||||
}
|
||||
}
|
||||
Column {
|
||||
spacing: 8
|
||||
|
||||
Label {
|
||||
text: "Frustum Items"
|
||||
}
|
||||
CheckBox {
|
||||
text: "Inside Items"
|
||||
checked: false
|
||||
onCheckedChanged: { root.itemSelection.showInsideItems = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Inside Sub-cell Items"
|
||||
checked: false
|
||||
onCheckedChanged: { root.itemSelection.showInsideSubcellItems = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Partial Items"
|
||||
checked: false
|
||||
onCheckedChanged: { root.itemSelection.showPartialItems = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Partial Sub-cell Items"
|
||||
checked: false
|
||||
onCheckedChanged: { root.itemSelection.showPartialSubcellItems = checked }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GroupBox {
|
||||
title: "Render Items"
|
||||
|
||||
Column{
|
||||
Repeater {
|
||||
model: [ "Opaque:DrawOpaqueDeferred", "Transparent:DrawTransparentDeferred", "Light:DrawLight",
|
||||
"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
|
||||
min: -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
examples/utilities/render/debugRender.js
Normal file
21
examples/utilities/render/debugRender.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// debugRender.js
|
||||
// examples/utilities/render
|
||||
//
|
||||
// Sam Gateau, created on 3/22/2016.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('culling.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Render Draws',
|
||||
source: qml,
|
||||
width: 300,
|
||||
height: 200
|
||||
});
|
||||
window.setPosition(200, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import "configSlider"
|
||||
|
||||
Column {
|
||||
id: root
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// PlotPerf.qml
|
||||
// examples/utilities/tools/render
|
||||
// examples/utilities/render/plotperf
|
||||
//
|
||||
// Created by Sam Gateau on 3//2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// stats.qml
|
||||
// examples/utilities/tools/render
|
||||
// examples/utilities/render
|
||||
//
|
||||
// Created by Zach Pomerantz on 2/8/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
|
@ -22,7 +22,7 @@ Item {
|
|||
anchors.fill:parent
|
||||
|
||||
property var config: Render.getConfig("Stats")
|
||||
|
||||
|
||||
function evalEvenHeight() {
|
||||
// Why do we have to do that manually ? cannot seem to find a qml / anchor / layout mode that does that ?
|
||||
return (height - spacing * (children.length - 1)) / children.length
|
||||
|
@ -65,5 +65,16 @@ Item {
|
|||
height: parent.evalEvenHeight()
|
||||
parameters: "1000:K:0:frameTriangleCount-frame-#E2334D:frameTriangleRate-rate-#1AC567-0.001-MT/s"
|
||||
}
|
||||
|
||||
property var deferredTaskConfig: Render.getConfig("RenderDeferredTask")
|
||||
property var drawLightConfig: deferredTaskConfig.getConfig("DrawLight")
|
||||
|
||||
PlotPerf {
|
||||
title: "Lights"
|
||||
config: parent.drawLightConfig
|
||||
height: parent.evalEvenHeight()
|
||||
parameters: "1::0:numDrawn-frame-#E2334D"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
//
|
||||
// debugRenderOctree.js
|
||||
// examples/utilities/tools
|
||||
//
|
||||
// Sam Gateau
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("cookies.js");
|
||||
|
||||
var panel = new Panel(10, 300);
|
||||
var drawOctree = Render.RenderDeferredTask.DrawSceneOctree;
|
||||
Render.RenderDeferredTask.DrawSceneOctree.enabled = true;
|
||||
Render.RenderDeferredTask.DrawItemSelection.enabled = true;
|
||||
|
||||
panel.newCheckbox("Show Octree Cells",
|
||||
function(value) { Render.RenderDeferredTask.DrawSceneOctree.showVisibleCells = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawSceneOctree.showVisibleCells); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
panel.newCheckbox("Show Empty Cells",
|
||||
function(value) { Render.RenderDeferredTask.DrawSceneOctree.showEmptyCells = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawSceneOctree.showEmptyCells); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
panel.newCheckbox("Freeze Frustum",
|
||||
function(value) { Render.RenderDeferredTask.FetchSceneSelection.freezeFrustum = value; Render.RenderDeferredTask.CullSceneSelection.freezeFrustum = value; },
|
||||
function() { return (Render.RenderDeferredTask.FetchSceneSelection.freezeFrustum); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
panel.newCheckbox("Show Inside Items",
|
||||
function(value) { Render.RenderDeferredTask.DrawItemSelection.showInsideItems = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawItemSelection.showInsideItems); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
|
||||
panel.newCheckbox("Show Inside Subcell Items",
|
||||
function(value) { Render.RenderDeferredTask.DrawItemSelection.showInsideSubcellItems = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawItemSelection.showInsideSubcellItems); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
|
||||
panel.newCheckbox("Show Partial Items",
|
||||
function(value) { Render.RenderDeferredTask.DrawItemSelection.showPartialItems = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawItemSelection.showPartialItems); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
|
||||
panel.newCheckbox("Show Partial Subcell Items",
|
||||
function(value) { Render.RenderDeferredTask.DrawItemSelection.showPartialSubcellItems = value; },
|
||||
function() { return (Render.RenderDeferredTask.DrawItemSelection.showPartialSubcellItems); },
|
||||
function(value) { return (value); }
|
||||
);
|
||||
|
||||
/*
|
||||
panel.newSlider('Cells Free / Allocated', -1, 1,
|
||||
function(value) { value; }, // setter
|
||||
function() { return Render.RenderDeferredTask.DrawSceneOctree.numFreeCells; }, // getter
|
||||
function(value) { return value; });
|
||||
|
||||
this.update = function () {
|
||||
var numFree = Render.RenderDeferredTask.DrawSceneOctree.numFreeCells;
|
||||
var numAlloc = Render.RenderDeferredTask.DrawSceneOctree.numAllocatedCells;
|
||||
var title = [
|
||||
' ' + name,
|
||||
numFree + ' / ' + numAlloc
|
||||
].join('\t');
|
||||
|
||||
widget.editTitle({ text: title });
|
||||
slider.setMaxValue(numAlloc);
|
||||
};
|
||||
*/
|
||||
function mouseMoveEvent(event) {
|
||||
panel.mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
function mousePressEvent(event) {
|
||||
panel.mousePressEvent(event);
|
||||
}
|
||||
|
||||
function mouseReleaseEvent(event) {
|
||||
panel.mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||
|
||||
function scriptEnding() {
|
||||
panel.destroy();
|
||||
Render.RenderDeferredTask.DrawSceneOctree.enabled = false;
|
||||
Render.RenderDeferredTask.DrawItemSelection.enabled = false;
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
|
|
@ -437,6 +437,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
|||
// we should be able to draw thre same geometry use DepthClamp but for unknown reason it's s not working...
|
||||
if ((eyeHalfPlaneDistance > -nearRadius) &&
|
||||
(glm::distance(eyePoint, glm::vec3(light->getPosition())) < expandedRadius + nearRadius)) {
|
||||
light->setShowContour(true);
|
||||
coneParam.w = 0.0f;
|
||||
batch._glUniform4fv(_spotLightLocations->coneParam, 1, reinterpret_cast< const float* >(&coneParam));
|
||||
|
||||
|
@ -452,6 +453,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
|||
batch.setProjectionTransform( projMats[side]);
|
||||
batch.setViewTransform(viewTransforms[side]);
|
||||
} else {
|
||||
light->setShowContour(false);
|
||||
coneParam.w = 1.0f;
|
||||
batch._glUniform4fv(_spotLightLocations->coneParam, 1, reinterpret_cast< const float* >(&coneParam));
|
||||
|
||||
|
|
|
@ -32,9 +32,10 @@ public:
|
|||
|
||||
class RenderDeferred {
|
||||
public:
|
||||
using JobModel = render::Job::Model<RenderDeferred>;
|
||||
|
||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||
|
||||
using JobModel = render::Job::Model<RenderDeferred>;
|
||||
};
|
||||
|
||||
class DrawConfig : public render::Job::Config {
|
||||
|
|
|
@ -25,6 +25,7 @@ in vec4 _texCoord0;
|
|||
out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
|
||||
DeferredTransform deferredTransform = getDeferredTransform();
|
||||
|
||||
// Grab the fragment data from the uv
|
||||
|
@ -36,6 +37,8 @@ void main(void) {
|
|||
// Kill if in front of the light volume
|
||||
float depth = frag.depthVal;
|
||||
if (depth < gl_FragCoord.z) {
|
||||
_fragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
return;
|
||||
discard;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,17 +20,14 @@ namespace render {
|
|||
class DrawSceneOctreeConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty())
|
||||
Q_PROPERTY(bool showVisibleCells MEMBER showVisibleCells WRITE setShowVisibleCells)
|
||||
Q_PROPERTY(bool showEmptyCells MEMBER showEmptyCells WRITE setShowEmptyCells)
|
||||
Q_PROPERTY(bool showVisibleCells READ getShowVisibleCells WRITE setShowVisibleCells NOTIFY dirty())
|
||||
Q_PROPERTY(bool showEmptyCells READ getShowEmptyCells WRITE setShowEmptyCells NOTIFY dirty())
|
||||
Q_PROPERTY(int numAllocatedCells READ getNumAllocatedCells)
|
||||
Q_PROPERTY(int numFreeCells READ getNumFreeCells)
|
||||
|
||||
public:
|
||||
|
||||
DrawSceneOctreeConfig() : Job::Config(false) {}
|
||||
|
||||
bool showVisibleCells{ true };
|
||||
bool showEmptyCells{ false };
|
||||
|
||||
int numAllocatedCells{ 0 };
|
||||
int numFreeCells{ 0 };
|
||||
|
@ -38,6 +35,12 @@ namespace render {
|
|||
int getNumAllocatedCells() const { return numAllocatedCells; }
|
||||
int getNumFreeCells() const { return numFreeCells; }
|
||||
|
||||
bool showVisibleCells{ true };
|
||||
bool showEmptyCells{ false };
|
||||
|
||||
bool getShowVisibleCells() { return showVisibleCells; }
|
||||
bool getShowEmptyCells() { return showEmptyCells; }
|
||||
|
||||
public slots:
|
||||
void setShowVisibleCells(bool show) { showVisibleCells = show; emit dirty(); }
|
||||
void setShowEmptyCells(bool show) { showEmptyCells = show; emit dirty(); }
|
||||
|
@ -79,10 +82,10 @@ namespace render {
|
|||
class DrawItemSelectionConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty())
|
||||
Q_PROPERTY(bool showInsideItems MEMBER showInsideItems WRITE setShowInsideItems)
|
||||
Q_PROPERTY(bool showInsideSubcellItems MEMBER showInsideSubcellItems WRITE setShowInsideSubcellItems)
|
||||
Q_PROPERTY(bool showPartialItems MEMBER showPartialItems WRITE setShowPartialItems)
|
||||
Q_PROPERTY(bool showPartialSubcellItems MEMBER showPartialSubcellItems WRITE setShowPartialSubcellItems)
|
||||
Q_PROPERTY(bool showInsideItems READ getShowInsideItems WRITE setShowInsideItems NOTIFY dirty())
|
||||
Q_PROPERTY(bool showInsideSubcellItems READ getShowInsideSubcellItems WRITE setShowInsideSubcellItems NOTIFY dirty())
|
||||
Q_PROPERTY(bool showPartialItems READ getShowPartialItems WRITE setShowPartialItems NOTIFY dirty())
|
||||
Q_PROPERTY(bool showPartialSubcellItems READ getShowPartialSubcellItems WRITE setShowPartialSubcellItems NOTIFY dirty())
|
||||
public:
|
||||
|
||||
DrawItemSelectionConfig() : Job::Config(false) {}
|
||||
|
@ -92,7 +95,12 @@ namespace render {
|
|||
bool showPartialItems{ true };
|
||||
bool showPartialSubcellItems{ true };
|
||||
|
||||
public slots:
|
||||
bool getShowInsideItems() const { return showInsideItems; };
|
||||
bool getShowInsideSubcellItems() const { return showInsideSubcellItems; };
|
||||
bool getShowPartialItems() const { return showPartialItems; };
|
||||
bool getShowPartialSubcellItems() const { return showPartialSubcellItems; };
|
||||
|
||||
public slots:
|
||||
void setShowInsideItems(bool show) { showInsideItems = show; emit dirty(); }
|
||||
void setShowInsideSubcellItems(bool show) { showInsideSubcellItems = show; emit dirty(); }
|
||||
void setShowPartialItems(bool show) { showPartialItems = show; emit dirty(); }
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
|
||||
using namespace render;
|
||||
|
||||
void render::renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {
|
||||
void render::renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, int maxDrawnItems) {
|
||||
auto& scene = sceneContext->_scene;
|
||||
RenderArgs* args = renderContext->args;
|
||||
|
||||
for (const auto& itemDetails : inItems) {
|
||||
auto& item = scene->getItem(itemDetails.id);
|
||||
int numItemsToDraw = (int)inItems.size();
|
||||
if (maxDrawnItems != -1) {
|
||||
numItemsToDraw = glm::min(numItemsToDraw, maxDrawnItems);
|
||||
}
|
||||
for (auto i = 0; i < numItemsToDraw; ++i) {
|
||||
auto& item = scene->getItem(inItems[i].id);
|
||||
item.render(args);
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +73,10 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
|
|||
// render lights
|
||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
renderItems(sceneContext, renderContext, inLights);
|
||||
renderItems(sceneContext, renderContext, inLights, _maxDrawn);
|
||||
args->_batch = nullptr;
|
||||
});
|
||||
|
||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
config->setNumDrawn((int)inLights.size());
|
||||
}
|
||||
|
|
|
@ -16,15 +16,37 @@
|
|||
|
||||
namespace render {
|
||||
|
||||
void renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems);
|
||||
void renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
||||
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemBounds& inItems, int maxDrawnItems = -1);
|
||||
|
||||
|
||||
|
||||
class DrawLightConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
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 maxDrawn{ -1 };
|
||||
signals:
|
||||
void numDrawnChanged();
|
||||
void dirty();
|
||||
|
||||
protected:
|
||||
int numDrawn{ 0 };
|
||||
};
|
||||
|
||||
class DrawLight {
|
||||
public:
|
||||
using JobModel = Job::ModelI<DrawLight, ItemBounds>;
|
||||
using Config = DrawLightConfig;
|
||||
using JobModel = Job::ModelI<DrawLight, ItemBounds, Config>;
|
||||
|
||||
void configure(const Config& config) { _maxDrawn = config.maxDrawn; }
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inLights);
|
||||
protected:
|
||||
int _maxDrawn; // initialized by Config
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue