mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 03:42:45 +02:00
Bringing the test to the workload ui
This commit is contained in:
parent
9cb918a4ad
commit
6acda83f5c
7 changed files with 154 additions and 241 deletions
|
@ -522,20 +522,11 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
|||
auto lightStage = renderContext->_scene->getStage<LightStage>();
|
||||
assert(lightStage);
|
||||
assert(lightStage->getNumLights() > 0);
|
||||
auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow();
|
||||
const auto& globalShadow = lightAndShadow.second;
|
||||
|
||||
// Bind the shadow buffers
|
||||
if (globalShadow) {
|
||||
for (unsigned int i = 0; i < globalShadow->getCascadeCount(); i++) {
|
||||
batch.setResourceTexture(SHADOW_MAP_UNIT+i, globalShadow->getCascade(i).map);
|
||||
}
|
||||
}
|
||||
|
||||
auto& program = deferredLightingEffect->_directionalSkyboxLight;
|
||||
auto program = deferredLightingEffect->_directionalSkyboxLight;
|
||||
LightLocationsPtr locations = deferredLightingEffect->_directionalSkyboxLightLocations;
|
||||
|
||||
auto keyLight = lightAndShadow.first;
|
||||
// auto keyLight = lightAndShadow.first;
|
||||
|
||||
graphics::LightPointer ambientLight;
|
||||
if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
|
||||
|
@ -556,6 +547,18 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
|||
}
|
||||
|
||||
if (deferredLightingEffect->_shadowMapEnabled && keyLightCastShadows) {
|
||||
auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow();
|
||||
const auto& globalShadow = lightAndShadow.second;
|
||||
|
||||
// Bind the shadow buffers
|
||||
if (globalShadow) {
|
||||
for (unsigned int i = 0; i < globalShadow->getCascadeCount(); i++) {
|
||||
batch.setResourceTexture(SHADOW_MAP_UNIT + i, globalShadow->getCascade(i).map);
|
||||
}
|
||||
if (locations->shadowTransformBuffer >= 0) {
|
||||
batch.setUniformBuffer(locations->shadowTransformBuffer, globalShadow->getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
// If the keylight has an ambient Map then use the Skybox version of the pass
|
||||
// otherwise use the ambient sphere version
|
||||
|
@ -578,12 +581,6 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
|||
}
|
||||
}
|
||||
|
||||
if (locations->shadowTransformBuffer >= 0) {
|
||||
if (globalShadow) {
|
||||
batch.setUniformBuffer(locations->shadowTransformBuffer, globalShadow->getBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
batch.setPipeline(program);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,21 +9,13 @@
|
|||
// 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("./test_simulation_scene.js")
|
||||
Script.include("./test_physics_scene.js")
|
||||
|
||||
(function() {
|
||||
var TABLET_BUTTON_NAME = "Test Sim";
|
||||
var QMLAPP_URL = Script.resolvePath("./testSimulationWorkload.qml");
|
||||
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
|
||||
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
|
||||
|
||||
var test = { scene:[] }
|
||||
test.clearScene = function clearScene() {
|
||||
for (var i = 0; i < this.scene.length; i++) {
|
||||
Entities.deleteEntity(this.scene[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var onAppScreen = false;
|
||||
|
||||
|
@ -72,13 +64,11 @@ Script.include("./test_simulation_scene.js")
|
|||
button.editProperties({isActive: onAppScreen});
|
||||
wireEventBridge(onAppScreen);
|
||||
}
|
||||
|
||||
function fromQml(message) {
|
||||
}
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
tablet.screenChanged.connect(onScreenChanged);
|
||||
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
if (onAppScreen) {
|
||||
tablet.gotoHomeScreen();
|
||||
|
@ -89,4 +79,21 @@ Script.include("./test_simulation_scene.js")
|
|||
clearScene();
|
||||
});
|
||||
|
||||
|
||||
function fromQml(message) {
|
||||
switch (message.method) {
|
||||
case "createScene":
|
||||
createScene();
|
||||
break;
|
||||
case "clearScene":
|
||||
clearScene();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendToQml(message) {
|
||||
tablet.sendToQml(message);
|
||||
}
|
||||
|
||||
}());
|
|
@ -14,7 +14,7 @@ import QtQuick.Layouts 1.3
|
|||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
import "../render/configSlider"
|
||||
import "./test_simulation_scene.js" as Sim
|
||||
//import "./test_simulation_scene.js" as Sim
|
||||
|
||||
|
||||
Rectangle {
|
||||
|
@ -27,19 +27,22 @@ Rectangle {
|
|||
|
||||
color: hifi.colors.baseGray;
|
||||
|
||||
property var scene : []
|
||||
|
||||
function clearScene() {
|
||||
for (var i = 0; i < _test.scene.length; i++) {
|
||||
Entities.deleteEntity(_test.scene[i]);
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
_test.scene = Sim.setupScene();
|
||||
|
||||
}
|
||||
Component.onDestruction: {
|
||||
clearScene()
|
||||
}
|
||||
|
||||
function broadcastCreateScene() {
|
||||
sendToScript({method: "createScene", params: { count:2 }});
|
||||
}
|
||||
|
||||
function broadcastClearScene() {
|
||||
sendToScript({method: "clearScene", params: { count:2 }});
|
||||
}
|
||||
|
||||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -55,6 +58,15 @@ Rectangle {
|
|||
HifiControls.Label {
|
||||
text: "Display"
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
text: "create scene"
|
||||
onClicked: {
|
||||
print("pressed")
|
||||
_test.broadcastCreateScene()
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
var DEFAULT_LIFETIME = 120;
|
||||
|
||||
var GRID_WORLD_SIZE = 100.0;
|
||||
var GRID_WORLD_RESOLUTION = 4.0;
|
||||
var GRID_WORLD_RESOLUTION = 2.0;
|
||||
|
||||
var BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION;
|
||||
var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
||||
|
@ -183,12 +183,28 @@ getStagePosOriAt = function (a, b, c) {
|
|||
}
|
||||
|
||||
|
||||
var scene = setupScene();
|
||||
var scene = []
|
||||
|
||||
createScene = function() {
|
||||
clearScene();
|
||||
scene = setupScene();
|
||||
}
|
||||
|
||||
// clean up after test
|
||||
Script.scriptEnding.connect(function () {
|
||||
clearScene = function() {
|
||||
for (var i = 0; i < scene.length; i++) {
|
||||
Entities.deleteEntity(scene[i]);
|
||||
}
|
||||
}
|
||||
|
||||
changeResolution = function(res) {
|
||||
GRID_WORLD_RESOLUTION = res;
|
||||
|
||||
BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION;
|
||||
BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
||||
|
||||
TILE_UNIT = GRID_WORLD_RESOLUTION;
|
||||
}
|
||||
// clean up after test
|
||||
Script.scriptEnding.connect(function () {
|
||||
clearScene()
|
||||
});
|
|
@ -1,194 +0,0 @@
|
|||
|
||||
var DEFAULT_LIFETIME = 120;
|
||||
|
||||
var GRID_WORLD_SIZE = 100.0;
|
||||
var GRID_WORLD_RESOLUTION = 4.0;
|
||||
|
||||
var BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION;
|
||||
var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
||||
var BACKDROP_MIN_C = -2;
|
||||
|
||||
var ROOT_Z_OFFSET = -3;
|
||||
var ROOT_Y_OFFSET = -0.1;
|
||||
|
||||
var TILE_UNIT = GRID_WORLD_RESOLUTION;
|
||||
var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT};
|
||||
var GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM);
|
||||
|
||||
var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5};
|
||||
|
||||
|
||||
var shapeTypes = [
|
||||
"none",
|
||||
"box",
|
||||
"sphere",
|
||||
"compound",
|
||||
"simple-hull",
|
||||
"simple-compound",
|
||||
"static-mesh"
|
||||
];
|
||||
|
||||
function getTileColor(a, b, c) {
|
||||
var offset = (Math.abs(a) + ((Math.abs(b) + (Math.abs(c) % 2)) % 2)) % 2;
|
||||
var intensity = (1 - offset) * 128 + offset * 255;
|
||||
return { red: intensity * (a % 4), green: intensity, blue: intensity * (b % 4) };
|
||||
}
|
||||
|
||||
function addObject(a, b, c, lifetime) {
|
||||
var center = Vec3.sum(stageTileRoot, Vec3.multiply(a, stageAxisA));
|
||||
center = Vec3.sum(center, Vec3.multiply(b, stageAxisB));
|
||||
center = Vec3.sum(center, Vec3.multiply(c, stageAxisC));
|
||||
|
||||
return (Entities.addEntity({
|
||||
type: "Shape",
|
||||
shape: "Sphere",
|
||||
name: "Backdrop",
|
||||
color: getTileColor(a, b, c),
|
||||
position: center,
|
||||
rotation: stageOrientation,
|
||||
dimensions: OBJECT_DIM,
|
||||
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
|
||||
shapeType:shapeTypes[2],
|
||||
dynamic: true,
|
||||
gravity:{"x":0,"y":-9.8,"z":0},
|
||||
velocity:{"x":0,"y":0.02,"z":0},
|
||||
restitution:0.70,
|
||||
friction:0.001,
|
||||
damping:0.001,
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
function addObjectGrid(backdrop, lifetime) {
|
||||
for (var i = BACKDROP_HALFSIZE; i > -BACKDROP_HALFSIZE; i--) {
|
||||
for (var j = -BACKDROP_HALFSIZE; j < BACKDROP_HALFSIZE; j++) {
|
||||
backdrop.push(addObject(i, j, BACKDROP_MIN_C + 2, lifetime));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function addFloor(lifetime) {
|
||||
var floorDim = { x:BACKDROP_SIZE * TILE_DIM.x, y:TILE_DIM.y, z:BACKDROP_SIZE *TILE_DIM.x};
|
||||
var center = getStagePosOriAt(0, 0, -1).pos;
|
||||
|
||||
return (Entities.addEntity({
|
||||
type: "Shape",
|
||||
shape: "Cube",
|
||||
name: "Floor",
|
||||
color: { red: 20, green: 20, blue: 40 },
|
||||
position: center,
|
||||
rotation: stageOrientation,
|
||||
dimensions: floorDim,
|
||||
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
|
||||
|
||||
shapeType:shapeTypes[1],
|
||||
// dynamic: true,
|
||||
// gravity:{"x":0,"y":-9.8,"z":0},
|
||||
// velocity:{"x":0,"y":0.01,"z":0},
|
||||
restitution:0.999,
|
||||
friction:0.000,
|
||||
damping:0.0,
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
function addZone(hasKeyLight, hasAmbient, lifetime) {
|
||||
var zoneDim = Vec3.multiply(BACKDROP_SIZE, TILE_DIM);
|
||||
var center = getStagePosOriAt(0, 0, 0).pos;
|
||||
|
||||
var lightDir = Vec3.normalize(Vec3.sum(Vec3.multiply(-1, Quat.getUp(stageOrientation)), Vec3.multiply(-1, Quat.getRight(stageOrientation))))
|
||||
|
||||
return (Entities.addEntity({
|
||||
type: "Zone",
|
||||
name: "Backdrop zone",
|
||||
|
||||
position: center,
|
||||
rotation: stageOrientation,
|
||||
dimensions: zoneDim,
|
||||
lifetime: (lifetime === undefined) ? DEFAULT_LIFETIME : lifetime,
|
||||
|
||||
keyLightMode: "enabled",
|
||||
skyboxMode: "enabled",
|
||||
ambientLightMode: "enabled",
|
||||
|
||||
keyLight:{
|
||||
intensity: 0.8 * hasKeyLight,
|
||||
direction: {
|
||||
"x": 0.037007175385951996,
|
||||
"y": -0.7071067690849304,
|
||||
"z": -0.7061376571655273
|
||||
},
|
||||
castShadows: true,
|
||||
},
|
||||
ambientLight: {
|
||||
ambientIntensity: 1.0 * hasAmbient,
|
||||
ambientURL: "https://github.com/highfidelity/hifi_tests/blob/master/assets/skymaps/Sky_Day-Sun-Mid-photo.ktx?raw=true",
|
||||
},
|
||||
|
||||
hazeMode:"disabled",
|
||||
backgroundMode:"skybox",
|
||||
skybox:{
|
||||
color: {"red":2,"green":2,"blue":2}, // Dark grey background
|
||||
skyboxURL: "https://github.com/highfidelity/hifi_tests/blob/master/assets/skymaps/Sky_Day-Sun-Mid-photo.ktx?raw=true",
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function addTestScene(name, lifetime) {
|
||||
var scene = [];
|
||||
scene.push(addFloor(lifetime));
|
||||
scene.push(addZone(true, true, lifetime));
|
||||
|
||||
addObjectGrid(scene, lifetime);
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Stage position and orientation initialised at setup
|
||||
stageOrientation = Quat.fromPitchYawRollDegrees(0.0, 0.0, 0.0);
|
||||
stageRoot = {"x":0.0,"y":0.0,"z":0.0};
|
||||
stageTileRoot = {"x":0.0,"y":0.0,"z":0.0};
|
||||
stageAxisA = Vec3.multiply(TILE_UNIT, Quat.getForward(stageOrientation));
|
||||
stageAxisB = Vec3.multiply(TILE_UNIT, Quat.getRight(stageOrientation));
|
||||
stageAxisC = Vec3.multiply(TILE_UNIT, Quat.getUp(stageOrientation));
|
||||
|
||||
setupScene = function (lifetime) {
|
||||
MyAvatar.orientation = Quat.fromPitchYawRollDegrees(0.0, 0.0, 0.0);
|
||||
var orientation = MyAvatar.orientation;
|
||||
orientation = Quat.safeEulerAngles(orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
|
||||
stageOrientation = orientation;
|
||||
stageAxisA = Vec3.multiply(TILE_UNIT, Quat.getForward(stageOrientation));
|
||||
stageAxisB = Vec3.multiply(TILE_UNIT, Quat.getRight(stageOrientation));
|
||||
stageAxisC = Vec3.multiply(TILE_UNIT, Quat.getUp(stageOrientation));
|
||||
|
||||
stageRoot = Vec3.sum(MyAvatar.position, Vec3.multiply(-ROOT_Z_OFFSET, Quat.getForward(orientation)));
|
||||
stageRoot = Vec3.sum(stageRoot, Vec3.multiply(ROOT_Y_OFFSET, Quat.getUp(orientation)));
|
||||
stageTileRoot = Vec3.sum(stageRoot, GRID_TILE_OFFSET);
|
||||
|
||||
return addTestScene("Physics_stage_backdrop", lifetime);
|
||||
}
|
||||
|
||||
getStagePosOriAt = function (a, b, c) {
|
||||
var center = Vec3.sum(stageRoot, Vec3.multiply(a, stageAxisA));
|
||||
center = Vec3.sum(center, Vec3.multiply(b, stageAxisB));
|
||||
center = Vec3.sum(center, Vec3.multiply(c, stageAxisC));
|
||||
|
||||
return { "pos": center, "ori": stageOrientation};
|
||||
}
|
||||
|
||||
|
||||
// var scene = setupScene();
|
||||
|
||||
|
||||
// clean up after test
|
||||
/*Script.scriptEnding.connect(function () {
|
||||
for (var i = 0; i < scene.length; i++) {
|
||||
Entities.deleteEntity(scene[i]);
|
||||
}
|
||||
});*/
|
|
@ -80,4 +80,26 @@
|
|||
tablet.removeButton(button);
|
||||
});
|
||||
|
||||
|
||||
Script.include("./test_physics_scene.js")
|
||||
|
||||
function fromQml(message) {
|
||||
switch (message.method) {
|
||||
case "createScene":
|
||||
createScene();
|
||||
break;
|
||||
case "clearScene":
|
||||
clearScene();
|
||||
break;
|
||||
case "changeResolution":
|
||||
changeResolution(message.params.count);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendToQml(message) {
|
||||
tablet.sendToQml(message);
|
||||
}
|
||||
|
||||
}());
|
|
@ -26,7 +26,24 @@ Rectangle {
|
|||
anchors.margins: hifi.dimensions.contentMargin.x
|
||||
|
||||
color: hifi.colors.baseGray;
|
||||
|
||||
|
||||
function broadcastCreateScene() {
|
||||
sendToScript({method: "createScene", params: { count:2 }});
|
||||
}
|
||||
|
||||
function broadcastClearScene() {
|
||||
sendToScript({method: "clearScene", params: { count:2 }});
|
||||
}
|
||||
|
||||
function broadcastChangeResolution(value) {
|
||||
sendToScript({method: "changeResolution", params: { count:value }});
|
||||
}
|
||||
|
||||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 5
|
||||
anchors.left: parent.left
|
||||
|
@ -136,13 +153,49 @@ Rectangle {
|
|||
onCheckedChanged: { Workload.getConfig("SpaceToRender")["showViews"] = checked }
|
||||
}
|
||||
Separator {}
|
||||
HifiControls.Label {
|
||||
text: "Test"
|
||||
}
|
||||
RowLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
HifiControls.Button {
|
||||
text: "create scene"
|
||||
onClicked: {
|
||||
print("pressed")
|
||||
_workload.broadcastCreateScene()
|
||||
}
|
||||
}
|
||||
HifiControls.Button {
|
||||
text: "clear scene"
|
||||
onClicked: {
|
||||
print("pressed")
|
||||
_workload.broadcastClearScene()
|
||||
}
|
||||
}
|
||||
}
|
||||
HifiControls.Slider {
|
||||
id: resolution
|
||||
stepSize: 1.0
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.top: root.top
|
||||
anchors.topMargin: 0
|
||||
minimumValue: 1
|
||||
maximumValue: 10
|
||||
|
||||
Jet.TaskList {
|
||||
onValueChanged: { _workload.broadcastChangeResolution(value) }
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
/*Jet.TaskList {
|
||||
rootConfig: Workload
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
height: 300
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue