Updated debugAmbientOcclussionPass script to tablet app

This commit is contained in:
Olivier Prat 2018-04-11 17:21:44 +02:00
parent d8f0cfa89a
commit 5978158358
2 changed files with 151 additions and 50 deletions

View file

@ -7,40 +7,60 @@
// 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 "../lib/plotperf"
Column {
spacing: 8
Rectangle {
HifiConstants { id: hifi;}
id: render;
anchors.margins: hifi.dimensions.contentMargin.x
color: hifi.colors.baseGray;
Column {
id: surfaceGeometry
spacing: 10
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: hifi.dimensions.contentMargin.x
Column{
Repeater {
model: [
"Radius:radius:2.0:false",
"Level:obscuranceLevel:1.0:false",
"Num Taps:numSamples:32:true",
"Taps Spiral:numSpiralTurns:10.0:false",
"Falloff Bias:falloffBias:0.2:false",
"Edge Sharpness:edgeSharpness:1.0:false",
"Blur Radius:blurRadius:10.0:false",
]
ConfigSlider {
label: qsTr(modelData.split(":")[0])
integral: (modelData.split(":")[3] == 'true')
config: Render.getConfig("RenderMainView.AmbientOcclusion")
property: modelData.split(":")[1]
max: modelData.split(":")[2]
min: 0.0
}
Repeater {
model: [
"Radius:radius:2.0:false",
"Level:obscuranceLevel:1.0:false",
"Num Taps:numSamples:32:true",
"Taps Spiral:numSpiralTurns:10.0:false",
"Falloff Bias:falloffBias:0.2:false",
"Edge Sharpness:edgeSharpness:1.0:false",
"Blur Radius:blurRadius:10.0:false",
]
ConfigSlider {
label: qsTr(modelData.split(":")[0])
integral: (modelData.split(":")[3] == 'true')
config: Render.getConfig("RenderMainView.AmbientOcclusion")
property: modelData.split(":")[1]
max: modelData.split(":")[2]
min: 0.0
width: 280
height:38
}
}
Row{
spacing: 10
anchors.left: parent.left
anchors.right: parent.right
Column {
spacing: 10
Repeater {
model: [
"resolutionLevel:resolutionLevel",
@ -48,19 +68,24 @@ Column {
"fetchMipsEnabled:fetchMipsEnabled",
"borderingEnabled:borderingEnabled"
]
CheckBox {
HifiControls.CheckBox {
boxSize: 20
text: qsTr(modelData.split(":")[0])
checked: Render.getConfig("RenderMainView.AmbientOcclusion")[modelData.split(":")[1]]
onCheckedChanged: { Render.getConfig("RenderMainView.AmbientOcclusion")[modelData.split(":")[1]] = checked }
}
}
}
Column {
spacing: 10
Repeater {
model: [
"debugEnabled:showCursorPixel"
]
CheckBox {
HifiControls.CheckBox {
boxSize: 20
text: qsTr(modelData.split(":")[0])
checked: Render.getConfig("RenderMainView.DebugAmbientOcclusion")[modelData.split(":")[1]]
onCheckedChanged: { Render.getConfig("RenderMainView.DebugAmbientOcclusion")[modelData.split(":")[1]] = checked }
@ -70,6 +95,8 @@ Column {
}
PlotPerf {
anchors.left: parent.left
anchors.right: parent.right
title: "Timing"
height: 50
object: Render.getConfig("RenderMainView.AmbientOcclusion")

View file

@ -1,38 +1,112 @@
//
// debugSurfaceGeometryPass.js
// debugAmbientOcclusionPass.js
// developer/utilities/render
//
// Created by Sam Gateau on 6/6/2016
// Copyright 2016 High Fidelity, Inc.
// Olivier Prat, created on 11/04/2018.
// Copyright 2017 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
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// Set up the qml ui
var qml = Script.resolvePath('ambientOcclusionPass.qml');
var window = new OverlayWindow({
title: 'Ambient Occlusion Pass',
source: qml,
width: 400, height: 300,
});
window.setPosition(Window.innerWidth - 420, 50 + 550 + 50);
window.closed.connect(function() { Script.stop(); });
(function() {
"use strict";
var TABLET_BUTTON_NAME = "SSAO";
var QMLAPP_URL = Script.resolvePath("./ambientOcclusionPass.qml");
var ICON_URL = Script.resolvePath("../../../system/assets/images/ssao-i.svg");
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/ssao-a.svg");
var moveDebugCursor = false;
Controller.mousePressEvent.connect(function (e) {
if (e.isMiddleButton) {
moveDebugCursor = true;
setDebugCursor(e.x, e.y);
Script.include([
Script.resolvePath("../../../system/libraries/stringHelpers.js"),
]);
var onScreen = false;
function onClicked() {
if (onScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
});
Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; });
Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); });
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
icon: ICON_URL,
activeIcon: ACTIVE_ICON_URL
});
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) {
onScreen = true;
} else {
onScreen = false;
}
button.editProperties({isActive: onScreen});
wireEventBridge(onScreen);
}
function fromQml(message) {
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
Script.scriptEnding.connect(function () {
if (onScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
});
/*
var moveDebugCursor = false;
Controller.mousePressEvent.connect(function (e) {
if (e.isMiddleButton) {
moveDebugCursor = true;
setDebugCursor(e.x, e.y);
}
});
Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; });
Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); });
function setDebugCursor(x, y) {
nx = (x / Window.innerWidth);
ny = 1.0 - ((y) / (Window.innerHeight - 32));
function setDebugCursor(x, y) {
nx = (x / Window.innerWidth);
ny = 1.0 - ((y) / (Window.innerHeight - 32));
Render.getConfig("RenderMainView").getConfig("DebugAmbientOcclusion").debugCursorTexcoord = { x: nx, y: ny };
}
*/
function cleanup() {
}
Script.scriptEnding.connect(cleanup);
}());
Render.getConfig("RenderMainView").getConfig("DebugAmbientOcclusion").debugCursorTexcoord = { x: nx, y: ny };
}