mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Setting up taa job and debug ui
This commit is contained in:
parent
c90c3717a7
commit
dfc0bb8bcc
5 changed files with 146 additions and 10 deletions
|
@ -171,20 +171,14 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fxaa_vert.h"
|
|
||||||
#include "fxaa_frag.h"
|
#include "fxaa_frag.h"
|
||||||
#include "fxaa_blend_frag.h"
|
#include "fxaa_blend_frag.h"
|
||||||
|
|
||||||
|
|
||||||
Antialiasing::Antialiasing() {
|
Antialiasing::Antialiasing() {
|
||||||
_geometryId = DependencyManager::get<GeometryCache>()->allocateID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Antialiasing::~Antialiasing() {
|
Antialiasing::~Antialiasing() {
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
|
||||||
if (geometryCache) {
|
|
||||||
geometryCache->releaseID(_geometryId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
||||||
|
@ -201,8 +195,6 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() {
|
||||||
|
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
_texcoordOffsetLoc = program->getUniforms().findLocation("texcoordOffset");
|
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||||
|
|
||||||
PrepareStencil::testMask(*state);
|
PrepareStencil::testMask(*state);
|
||||||
|
@ -236,6 +228,12 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
|
||||||
return _blendPipeline;
|
return _blendPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Antialiasing::configure(const Config& config) {
|
||||||
|
_params.edit().debugX = config.debugX;
|
||||||
|
_params.edit().blend = config.blend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Antialiasing::run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer) {
|
void Antialiasing::run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->hasViewFrustum());
|
assert(renderContext->args->hasViewFrustum());
|
||||||
|
@ -269,6 +267,9 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
||||||
batch.setResourceTexture(0, sourceBuffer->getRenderBuffer(0));
|
batch.setResourceTexture(0, sourceBuffer->getRenderBuffer(0));
|
||||||
batch.setFramebuffer(_antialiasingBuffer);
|
batch.setFramebuffer(_antialiasingBuffer);
|
||||||
batch.setPipeline(getAntialiasingPipeline());
|
batch.setPipeline(getAntialiasingPipeline());
|
||||||
|
|
||||||
|
batch.setUniformBuffer(0, _params._buffer);
|
||||||
|
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
||||||
// Blend step
|
// Blend step
|
||||||
|
|
|
@ -18,10 +18,29 @@
|
||||||
|
|
||||||
class AntialiasingConfig : public render::Job::Config {
|
class AntialiasingConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
|
||||||
|
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AntialiasingConfig() : render::Job::Config(true) {}
|
AntialiasingConfig() : render::Job::Config(true) {}
|
||||||
|
|
||||||
|
float debugX{ 1.0f };
|
||||||
|
float blend { 0.1f };
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TAAParams {
|
||||||
|
float debugX{ 1.0f };
|
||||||
|
float blend{ 0.1f };
|
||||||
|
float spareA;
|
||||||
|
float spareB;
|
||||||
|
|
||||||
|
};
|
||||||
|
using TAAParamsBuffer = gpu::StructBuffer<TAAParams>;
|
||||||
|
|
||||||
class Antialiasing {
|
class Antialiasing {
|
||||||
public:
|
public:
|
||||||
using Config = AntialiasingConfig;
|
using Config = AntialiasingConfig;
|
||||||
|
@ -29,12 +48,15 @@ public:
|
||||||
|
|
||||||
Antialiasing();
|
Antialiasing();
|
||||||
~Antialiasing();
|
~Antialiasing();
|
||||||
void configure(const Config& config) {}
|
void configure(const Config& config);
|
||||||
void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer);
|
void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer);
|
||||||
|
|
||||||
const gpu::PipelinePointer& getAntialiasingPipeline();
|
const gpu::PipelinePointer& getAntialiasingPipeline();
|
||||||
const gpu::PipelinePointer& getBlendPipeline();
|
const gpu::PipelinePointer& getBlendPipeline();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Uniforms for AA
|
// Uniforms for AA
|
||||||
|
@ -46,7 +68,8 @@ private:
|
||||||
|
|
||||||
gpu::PipelinePointer _antialiasingPipeline;
|
gpu::PipelinePointer _antialiasingPipeline;
|
||||||
gpu::PipelinePointer _blendPipeline;
|
gpu::PipelinePointer _blendPipeline;
|
||||||
int _geometryId { 0 };
|
|
||||||
|
TAAParamsBuffer _params;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
45
libraries/render-utils/src/taa.slf
Normal file
45
libraries/render-utils/src/taa.slf
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// taa.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 8/14/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
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform sampler2D colorTexture;
|
||||||
|
//uniform sampler2D historyTexture;
|
||||||
|
|
||||||
|
in vec2 varTexCoord0;
|
||||||
|
layout(location = 0) out vec4 outFragColor;
|
||||||
|
|
||||||
|
struct TAAParams
|
||||||
|
{
|
||||||
|
float debugX;
|
||||||
|
float blend;
|
||||||
|
float spareA;
|
||||||
|
float spareB;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(std140, location=0) uniform taaParamsBuffer {
|
||||||
|
TAAParams params;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
outFragColor = vec4(texture(colorTexture, varTexCoord0).xyz, params.blend);
|
||||||
|
|
||||||
|
if (varTexCoord0.x < params.debugX) {
|
||||||
|
outFragColor.a = 1.0;
|
||||||
|
}
|
||||||
|
}
|
21
scripts/developer/utilities/render/antialiasing.js
Normal file
21
scripts/developer/utilities/render/antialiasing.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
//
|
||||||
|
// antialiasing.js
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 8/14/2017
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
// Set up the qml ui
|
||||||
|
var qml = Script.resolvePath('antialiasing.qml');
|
||||||
|
var window = new OverlayWindow({
|
||||||
|
title: 'Antialiasing',
|
||||||
|
source: qml,
|
||||||
|
width: 400, height:400,
|
||||||
|
});
|
||||||
|
window.setPosition(Window.innerWidth - 420, 50);
|
||||||
|
window.closed.connect(function() { Script.stop(); });
|
||||||
|
|
||||||
|
|
46
scripts/developer/utilities/render/antialiasing.qml
Normal file
46
scripts/developer/utilities/render/antialiasing.qml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// Antialiasing.qml
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 8/14/2017
|
||||||
|
// 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"
|
||||||
|
import "../lib/plotperf"
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 8
|
||||||
|
Column {
|
||||||
|
id: antialiasing
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Column{
|
||||||
|
ConfigSlider {
|
||||||
|
label: qsTr("Debug X")
|
||||||
|
integral: false
|
||||||
|
config: Render.getConfig("RenderMainView.Antialiasing")
|
||||||
|
property: "debugX"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
}
|
||||||
|
ConfigSlider {
|
||||||
|
label: qsTr("History blend")
|
||||||
|
integral: false
|
||||||
|
config: Render.getConfig("RenderMainView.Antialiasing")
|
||||||
|
property: "blend"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Freeze "
|
||||||
|
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]
|
||||||
|
onCheckedChanged: { Render.getConfig("RenderMainView.JitterCam")["freeze"] = checked }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue