mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 09:29:16 +02:00
AH ah moment and exploring using the tablet with html
This commit is contained in:
parent
4cdbefc440
commit
051f8c5b40
8 changed files with 167 additions and 56 deletions
|
@ -279,19 +279,14 @@ const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() {
|
|||
}
|
||||
|
||||
void Antialiasing::configure(const Config& config) {
|
||||
_params.edit().debugX = config.debugX;
|
||||
_params.edit().blend = config.blend;
|
||||
_params.edit().velocityScale = config.velocityScale;
|
||||
_params.edit().debugShowVelocityThreshold = config.debugShowVelocityThreshold;
|
||||
|
||||
_params.edit().debugCursor.x = config.showCursorPixel;
|
||||
|
||||
auto orbZoom = (_params->pixelInfo.z);
|
||||
auto cursorPos = glm::vec2(_params->pixelInfo);
|
||||
if (cursorPos != config.debugCursorTexcoord || (orbZoom != config.debugOrbZoom)) {
|
||||
_params.edit().pixelInfo = glm::vec4(config.debugCursorTexcoord, config.debugOrbZoom, 0.0f);
|
||||
}
|
||||
|
||||
_params.edit().debugX = config.debugX;
|
||||
_params.edit().setDebug(config.debug);
|
||||
_params.edit().setDebugCursor(config.debugCursorTexcoord);
|
||||
_params.edit().setDebugOrbZoom(config.debugOrbZoom);
|
||||
}
|
||||
|
||||
|
||||
|
@ -352,10 +347,10 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
batch.setResourceTexture(AntialiasingPass_SourceMapSlot, nullptr);
|
||||
|
||||
batch.setFramebuffer(sourceBuffer);
|
||||
if (_params->debugX <= 0.0) {
|
||||
batch.setPipeline(getBlendPipeline());
|
||||
} else {
|
||||
if (_params->isDebug()) {
|
||||
batch.setPipeline(getDebugBlendPipeline());
|
||||
} else {
|
||||
batch.setPipeline(getBlendPipeline());
|
||||
}
|
||||
batch.setResourceTexture(AntialiasingPass_NextMapSlot, _antialiasingTexture[nextFrame]);
|
||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
|
||||
class AntialiasingConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
|
||||
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
|
||||
Q_PROPERTY(float velocityScale MEMBER velocityScale NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool debug MEMBER debug NOTIFY dirty)
|
||||
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
|
||||
Q_PROPERTY(float debugShowVelocityThreshold MEMBER debugShowVelocityThreshold NOTIFY dirty)
|
||||
Q_PROPERTY(bool showCursorPixel MEMBER showCursorPixel NOTIFY dirty)
|
||||
Q_PROPERTY(glm::vec2 debugCursorTexcoord MEMBER debugCursorTexcoord NOTIFY dirty)
|
||||
|
@ -30,15 +32,17 @@ class AntialiasingConfig : public render::Job::Config {
|
|||
public:
|
||||
AntialiasingConfig() : render::Job::Config(true) {}
|
||||
|
||||
float debugX{ 0.0f };
|
||||
float blend{ 0.1f };
|
||||
float velocityScale{ 1.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
|
||||
bool showCursorPixel{ false };
|
||||
float debugX{ 0.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
glm::vec2 debugCursorTexcoord{ 0.5f, 0.5f };
|
||||
float debugOrbZoom{ 2.0f };
|
||||
|
||||
bool debug { false };
|
||||
bool showCursorPixel { false };
|
||||
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
@ -50,9 +54,18 @@ struct TAAParams {
|
|||
float velocityScale{ 1.0f };
|
||||
float debugShowVelocityThreshold{ 1.0f };
|
||||
|
||||
glm::vec4 debugCursor{ 0.0f };
|
||||
glm::vec4 debug{ 0.0f };
|
||||
glm::vec4 pixelInfo{ 0.5f, 0.5f, 2.0f, 0.0f };
|
||||
|
||||
void setDebug(bool enabled) { debug.x = (float)enabled; }
|
||||
bool isDebug() const { return (bool) debug.x; }
|
||||
|
||||
void setDebugCursor(glm::vec2 debugCursor) { pixelInfo.x = debugCursor.x; pixelInfo.y = debugCursor.y; }
|
||||
glm::vec2 getDebugCursor() const { return glm::vec2(pixelInfo.x, pixelInfo.y); }
|
||||
|
||||
void setDebugOrbZoom(float orbZoom) { pixelInfo.z = orbZoom; }
|
||||
float getDebugOrbZoom() const { return pixelInfo.z; }
|
||||
|
||||
};
|
||||
using TAAParamsBuffer = gpu::StructBuffer<TAAParams>;
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ layout(location = 0) out vec4 outFragColor;
|
|||
|
||||
void main() {
|
||||
|
||||
vec2 fragUV = find_closest_fragment_3x3(varTexCoord0);
|
||||
vec3 sourceColor = texture(sourceMap, fragUV).xyz;
|
||||
vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
|
||||
vec3 sourceColor = texture(sourceMap, fragUV.xy).xyz;
|
||||
|
||||
vec2 pixVelocity = texture(velocityMap, fragUV).xy;
|
||||
vec2 velocity = params.motionScale * pixVelocity;// *getInvWidthHeight();
|
||||
vec2 pixVelocity = texture(velocityMap, fragUV.xy).xy;
|
||||
vec2 velocity = params.motionScale * pixVelocity;
|
||||
vec2 prevTexCoord = varTexCoord0 - velocity;
|
||||
|
||||
vec3 historyColor = sourceColor;
|
||||
|
|
|
@ -33,41 +33,37 @@ layout(std140) uniform taaParamsBuffer {
|
|||
TAAParams params;
|
||||
};
|
||||
|
||||
vec2 getDebugCursorTexcoord() {
|
||||
vec2 taa_getDebugCursorTexcoord() {
|
||||
return params.pixelInfo_orbZoom.xy;
|
||||
}
|
||||
|
||||
float getOrbZoom() {
|
||||
float taa_getDebugOrbZoom() {
|
||||
return params.pixelInfo_orbZoom.z;
|
||||
}
|
||||
|
||||
float fetchDepth(vec2 uv) {
|
||||
float taa_fetchDepth(vec2 uv) {
|
||||
return texture(depthMap, vec2(uv), 0).x;
|
||||
}
|
||||
|
||||
float resolveDepthLinear(float depth) {
|
||||
return Zeye = -evalZeyeFromZdb(Zdb);
|
||||
}
|
||||
|
||||
#define ZCMP_GT(a, b) (a < b)
|
||||
|
||||
vec3 find_closest_fragment_3x3(vec2 uv)
|
||||
vec3 taa_findClosestFragment3x3(vec2 uv)
|
||||
{
|
||||
vec2 dd = abs(getInvWidthHeight());
|
||||
vec2 du = vec2(dd.x, 0.0);
|
||||
vec2 dv = vec2(0.0, dd.y);
|
||||
|
||||
vec3 dtl = vec3(-1, -1, fetchDepth(uv - dv - du);
|
||||
vec3 dtc = vec3( 0, -1, fetchDepth(uv - dv).x);
|
||||
vec3 dtr = vec3( 1, -1, fetchDepth(uv - dv + du);
|
||||
vec3 dtl = vec3(-1, -1, taa_fetchDepth(uv - dv - du));
|
||||
vec3 dtc = vec3( 0, -1, taa_fetchDepth(uv - dv));
|
||||
vec3 dtr = vec3( 1, -1, taa_fetchDepth(uv - dv + du));
|
||||
|
||||
vec3 dml = vec3(-1, 0, fetchDepth(CameraDepthTexture, uv - du);
|
||||
vec3 dmc = vec3( 0, 0, fetchDepth(CameraDepthTexture, uv);
|
||||
vec3 dmr = vec3( 1, 0, fetchDepth(CameraDepthTexture, uv + du);
|
||||
vec3 dml = vec3(-1, 0, taa_fetchDepth(uv - du));
|
||||
vec3 dmc = vec3( 0, 0, taa_fetchDepth(uv));
|
||||
vec3 dmr = vec3( 1, 0, taa_fetchDepth(uv + du));
|
||||
|
||||
vec3 dbl = vec3(-1, 1, fetchDepth(CameraDepthTexture, uv + dv - du);
|
||||
vec3 dbc = vec3( 0, 1, fetchDepth(CameraDepthTexture, uv + dv);
|
||||
vec3 dbr = vec3( 1, 1, fetchDepth(CameraDepthTexture, uv + dv + du);
|
||||
vec3 dbl = vec3(-1, 1, taa_fetchDepth(uv + dv - du));
|
||||
vec3 dbc = vec3( 0, 1, taa_fetchDepth(uv + dv));
|
||||
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
|
||||
|
||||
vec3 dmin = dtl;
|
||||
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
|
||||
|
@ -88,10 +84,10 @@ vec3 find_closest_fragment_3x3(vec2 uv)
|
|||
<@include gpu/Color.slh@>
|
||||
<$declareColorWheel()$>
|
||||
|
||||
vec3 getVelocityColorRelative(float velocityPixLength) {
|
||||
vec3 taa_getVelocityColorRelative(float velocityPixLength) {
|
||||
return colorRamp(velocityPixLength/params.debugShowVelocityThreshold);
|
||||
}
|
||||
|
||||
vec3 getVelocityColorAboveThreshold(float velocityPixLength) {
|
||||
vec3 taa_getVelocityColorAboveThreshold(float velocityPixLength) {
|
||||
return colorRamp((velocityPixLength - params.debugShowVelocityThreshold)/params.debugShowVelocityThreshold);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void main(void) {
|
|||
vec2 prevPix = prevTexCoord * imageSize;
|
||||
|
||||
// Pixel Debugged
|
||||
vec3 cursorFrag = find_closest_fragment_3x3(getDebugCursorTexcoord());
|
||||
vec3 cursorFrag = taa_findClosestFragment3x3(taa_getDebugCursorTexcoord());
|
||||
vec2 cursorUV = cursorFrag.xy;
|
||||
vec2 cursorPixelPos = cursorUV * imageSize;
|
||||
vec2 cursorVelocity = texture(velocityMap, cursorUV).xy;
|
||||
|
@ -52,7 +52,7 @@ void main(void) {
|
|||
|
||||
if ((dot(cursorVelocityDir, cursorToFragVec) < 0) && abs(dot(cursorVelocityNor, cursorToFragVec)) < 1.0) {
|
||||
|
||||
vec3 speedColor = getVelocityColorRelative(cursorToFragLength);
|
||||
vec3 speedColor = taa_getVelocityColorRelative(cursorToFragLength);
|
||||
|
||||
outFragColor = vec4(speedColor, 1.0);
|
||||
return;
|
||||
|
@ -64,18 +64,19 @@ void main(void) {
|
|||
|
||||
vec2 nextOrbPos = vec2(centerWidth, imageSize.y - 3 * tenPercentHeight);
|
||||
vec2 nextOrbPosToPix = pixPos - nextOrbPos;
|
||||
float nextOrbPosToPixLength = length(nextOrbPosToPix);
|
||||
|
||||
vec2 prevOrbPos = nextOrbPos + cursorVelocityDir * 2.0 * tenPercentHeight;
|
||||
vec2 prevOrbPosToPix = pixPos - prevOrbPos;
|
||||
float prevOrbPosToPixLength = length(prevOrbPosToPix);
|
||||
|
||||
if (dot(prevOrbPosToPix, prevOrbPosToPix) < tenPercentHeight * tenPercentHeight) {
|
||||
vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * getInvWidthHeight() / getOrbZoom();
|
||||
if ((prevOrbPosToPixLength < tenPercentHeight) && (cursorVelocityLength > 0.5)) {
|
||||
vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * getInvWidthHeight() / taa_getDebugOrbZoom();
|
||||
vec3 preOrbColor = vec3(0.0);
|
||||
if (!(any(lessThan(prevOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(prevOrbPosToPix_uv, vec2(1.0))))) {
|
||||
preOrbColor = texture(historyMap, prevOrbPosToPix_uv).xyz;
|
||||
}
|
||||
float distanceToPrev = length(prevOrbPosToPix);
|
||||
if (distanceToPrev < 2.0) {
|
||||
if (prevOrbPosToPixLength < 2.0) {
|
||||
preOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv));
|
||||
|
@ -85,8 +86,8 @@ void main(void) {
|
|||
outFragColor = vec4(preOrbColor, 1.0);
|
||||
return;
|
||||
}
|
||||
if (dot(nextOrbPosToPix, nextOrbPosToPix) < tenPercentHeight * tenPercentHeight) {
|
||||
vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * getInvWidthHeight() / getOrbZoom();
|
||||
if (nextOrbPosToPixLength < tenPercentHeight) {
|
||||
vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * getInvWidthHeight() / taa_getDebugOrbZoom();
|
||||
vec3 nextOrbColor = vec3(0.0);
|
||||
if (!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))) {
|
||||
nextOrbColor = texture(nextMap, nextOrbPosToPix_uv).xyz;
|
||||
|
@ -95,8 +96,7 @@ void main(void) {
|
|||
if (distanceToPrev < 2.0) {
|
||||
nextOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
float distanceToNext = length(nextOrbPosToPix);
|
||||
if (distanceToNext < 2.0) {
|
||||
if (nextOrbPosToPixLength < 2.0) {
|
||||
nextOrbColor = vec3(1.0, 0.5, 0.0);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ void main(void) {
|
|||
outFragColor.xyz = prevColor;
|
||||
|
||||
if (pixVelocityLength > params.debugShowVelocityThreshold) {
|
||||
vec3 speedColor = getVelocityColorAboveThreshold(pixVelocityLength);
|
||||
vec3 speedColor = taa_getVelocityColorAboveThreshold(pixVelocityLength);
|
||||
|
||||
outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void main(void) {
|
|||
ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide);
|
||||
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
float Zeye = -evalZeyeFromZdb(Zdb);
|
||||
float Zeye = evalZeyeFromZdb(Zdb);
|
||||
if (Zeye <= -getPosLinearDepthFar()) {
|
||||
outFragColor = vec4(0.5, 0.5, 0.0, 0.0);
|
||||
return;
|
||||
|
|
99
scripts/developer/utilities/render/TestQML/qml_app.js
Normal file
99
scripts/developer/utilities/render/TestQML/qml_app.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
"use strict";
|
||||
|
||||
//
|
||||
// gemstoneMagicMaker.js
|
||||
// tablet-sample-app
|
||||
//
|
||||
// Created by Faye Li on Feb 6 2017.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
(function() {
|
||||
var TABLET_BUTTON_NAME = "LUCI";
|
||||
var QMLAPP_URL = Script.resolvePath("../antialiasing.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);
|
||||
|
||||
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); });
|
||||
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
if (onLuciScreen) {
|
||||
tablet.gotoHomeScreen();
|
||||
}
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.screenChanged.disconnect(onScreenChanged);
|
||||
tablet.removeButton(button);
|
||||
});
|
||||
|
||||
function setDebugCursor(x, y) {
|
||||
nx = (x / Window.innerWidth);
|
||||
ny = 1.0 - ((y) / (Window.innerHeight - 32));
|
||||
|
||||
Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny };
|
||||
}
|
||||
|
||||
}());
|
|
@ -8,12 +8,15 @@
|
|||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 1.4
|
||||
import "configSlider"
|
||||
import "../lib/plotperf"
|
||||
|
||||
Column {
|
||||
spacing: 8
|
||||
id: root;
|
||||
// color: hifi.colors.baseGray;
|
||||
|
||||
Column {
|
||||
id: antialiasing
|
||||
spacing: 20
|
||||
|
@ -36,9 +39,14 @@ Column {
|
|||
min: 0.0
|
||||
}
|
||||
CheckBox {
|
||||
text: "Freeze "
|
||||
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.JitterCam")["freeze"] = checked }
|
||||
text: "Debug"
|
||||
checked: Render.getConfig("RenderMainView.Antialiasing")["debug"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.Antialiasing")["debug"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Freeze "
|
||||
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]
|
||||
onCheckedChanged: { Render.getConfig("RenderMainView.JitterCam")["freeze"] = checked }
|
||||
}
|
||||
ConfigSlider {
|
||||
label: qsTr("Debug X")
|
||||
|
|
Loading…
Reference in a new issue