Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved TAA with Velocity Buffer #1213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ Flickable {
ListModel {
id: antialiasingModel

// Maintain same order as "AntialiasingConfig::Mode".
// Maintain same order as "AntialiasingSetupConfig::Mode".
ListElement {
text: "None"
}
Expand Down
4 changes: 2 additions & 2 deletions interface/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,8 +2137,8 @@ void Application::initialize(const QCommandLineParser &parser) {
}
return glm::vec3(1.0f);
});
Procedural::opaqueStencil = [](gpu::StatePointer state) { PrepareStencil::testMaskDrawShape(*state); };
Procedural::transparentStencil = [](gpu::StatePointer state) { PrepareStencil::testMask(*state); };
Procedural::opaqueStencil = [](gpu::StatePointer state, bool useAA) { useAA ? PrepareStencil::testMaskDrawShape(*state) : PrepareStencil::testMaskDrawShapeNoAA(*state); };
Procedural::transparentStencil = [](gpu::StatePointer state) { PrepareStencil::testMaskResetNoAA(*state); };

EntityTree::setGetEntityObjectOperator([this](const QUuid& id) -> QObject* {
auto entities = getEntities();
Expand Down
2 changes: 1 addition & 1 deletion interface/src/SecondaryCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class EndSecondaryCameraFrame { // Restores renderContext.
void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor) {
const auto cachedArg = task.addJob<SecondaryCameraJob>("SecondaryCamera");

task.addJob<RenderViewTask>("RenderSecondView", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1);
task.addJob<RenderViewTask>("RenderSecondView", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1, RenderViewTask::TransformOffset::SECONDARY_VIEW);

task.addJob<EndSecondaryCameraFrame>("EndSecondaryCamera", cachedArg);
}
4 changes: 2 additions & 2 deletions interface/src/graphics/GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ void GraphicsEngine::render_performFrame() {
batch.enableStereo(isStereo);
batch.clearDepthStencilFramebuffer(1.0, 0);
batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() });
_splashScreen->render(batch, viewFrustum, renderArgs._renderMethod == RenderArgs::RenderMethod::FORWARD);
_splashScreen->render(batch, viewFrustum, renderArgs._renderMethod == RenderArgs::RenderMethod::FORWARD, render::RenderEngine::TS_BACKGROUND_VIEW);
});
} else {
{
PROFILE_RANGE(render, "/renderOverlay");
PerformanceTimer perfTimer("renderOverlay");
// NOTE: There is no batch associated with this renderArgs
// the ApplicationOverlay class assumes it's viewport is set up to be the device size
// the ApplicationOverlay class assumes its viewport is set up to be the device size
renderArgs._viewport = glm::ivec4(0, 0, qApp->getDeviceSize());
qApp->getApplicationOverlay().renderOverlay(&renderArgs);
}
Expand Down
7 changes: 5 additions & 2 deletions interface/src/raypick/ParabolaPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,10 @@ void ParabolaPointer::RenderState::ParabolaRenderItem::render(RenderArgs* args)

Transform transform;
transform.setTranslation(_origin);
batch.setModelTransform(transform);
batch.setModelTransform(transform, _prevRenderTransform);
if (args->_renderMode == RenderArgs::RenderMode::DEFAULT_RENDER_MODE || args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE) {
_prevRenderTransform = transform;
}

batch.setPipeline(getParabolaPipeline(args->_renderMethod == render::Args::RenderMethod::FORWARD));

Expand Down Expand Up @@ -481,4 +484,4 @@ namespace render {
template <> const ShapeKey shapeGetShapeKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload) {
return ShapeKey::Builder::ownPipeline();
}
}
}
2 changes: 2 additions & 0 deletions interface/src/raypick/ParabolaPointer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Sam Gondelman 7/17/2018
// Copyright 2018 High Fidelity, Inc.
// Copyright 2024 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand Down Expand Up @@ -62,6 +63,7 @@ class ParabolaPointer : public PathPointer {
render::ItemKey _key;

glm::vec3 _origin { 0.0f };
Transform _prevRenderTransform;
bool _isVisibleInSecondaryCamera { DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA };
bool _drawInFront { DEFAULT_PARABOLA_DRAWINFRONT };
bool _visible { false };
Expand Down
86 changes: 50 additions & 36 deletions interface/src/scripting/RenderScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
auto scriptEngine = manager->engine().get();

scriptRegisterMetaType<RenderScriptingInterface::RenderMethod, scriptValueFromEnumClass<RenderScriptingInterface::RenderMethod>, scriptValueToEnumClass<RenderScriptingInterface::RenderMethod> >(scriptEngine, "RenderMethod");
scriptRegisterMetaType<AntialiasingConfig::Mode, scriptValueFromEnumClass<AntialiasingConfig::Mode>, scriptValueToEnumClass<AntialiasingConfig::Mode> >(scriptEngine, "Mode");
scriptRegisterMetaType<AntialiasingSetupConfig::Mode, scriptValueFromEnumClass<AntialiasingSetupConfig::Mode>, scriptValueToEnumClass<AntialiasingSetupConfig::Mode> >(scriptEngine, "Mode");
}));

STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
auto scriptEngine = manager->engine().get();

scriptEngine->registerEnum("Render.RenderMethod",QMetaEnum::fromType<RenderScriptingInterface::RenderMethod>());
scriptEngine->registerEnum("AntialiasingMode",QMetaEnum::fromType<AntialiasingConfig::Mode>());
scriptEngine->registerEnum("AntialiasingMode",QMetaEnum::fromType<AntialiasingSetupConfig::Mode>());
});

RenderScriptingInterface* RenderScriptingInterface::getInstance() {
Expand All @@ -53,7 +53,7 @@ void RenderScriptingInterface::loadSettings() {
_bloomEnabled = _bloomEnabledSetting.get();
_ambientOcclusionEnabled = _ambientOcclusionEnabledSetting.get();
_proceduralMaterialsEnabled = _proceduralMaterialsEnabledSetting.get();
_antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());
_antialiasingMode = static_cast<AntialiasingSetupConfig::Mode>(_antialiasingModeSetting.get());
_viewportResolutionScale = _viewportResolutionScaleSetting.get();
_fullScreenScreen = _fullScreenScreenSetting.get();
});
Expand Down Expand Up @@ -92,9 +92,10 @@ void recursivelyUpdateMirrorRenderMethods(const QString& parentTaskName, int ren
return;
}

auto renderConfig = qApp->getRenderEngine()->getConfiguration();
for (size_t mirrorIndex = 0; mirrorIndex < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; mirrorIndex++) {
std::string mirrorTaskString = parentTaskName.toStdString() + ".RenderMirrorView" + std::to_string(mirrorIndex) + "Depth" + std::to_string(depth) + ".DeferredForwardSwitch";
auto mirrorConfig = dynamic_cast<render::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig(QString::fromStdString(mirrorTaskString)));
auto mirrorConfig = dynamic_cast<render::SwitchConfig*>(renderConfig->getConfig(QString::fromStdString(mirrorTaskString)));
if (mirrorConfig) {
mirrorConfig->setBranch((int)renderMethod);
recursivelyUpdateMirrorRenderMethods(QString::fromStdString(mirrorTaskString) + (renderMethod == 1 ? ".RenderForwardTask" : ".RenderShadowsAndDeferredTask.RenderDeferredTask"),
Expand All @@ -108,14 +109,20 @@ void RenderScriptingInterface::forceRenderMethod(RenderMethod renderMethod) {
_renderMethod = (int)renderMethod;
_renderMethodSetting.set((int)renderMethod);

auto renderConfig = qApp->getRenderEngine()->getConfiguration();
QString configName = "RenderMainView.DeferredForwardSwitch";
auto config = dynamic_cast<render::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig(configName));
auto config = dynamic_cast<render::SwitchConfig*>(renderConfig->getConfig(configName));
if (config) {
config->setBranch((int)renderMethod);

recursivelyUpdateMirrorRenderMethods(configName + (renderMethod == RenderMethod::FORWARD ? ".RenderForwardTask" : ".RenderShadowsAndDeferredTask.RenderDeferredTask"),
(int)renderMethod, 0);
}

auto secondaryConfig = dynamic_cast<render::SwitchConfig*>(renderConfig->getConfig("RenderSecondView.DeferredForwardSwitch"));
if (secondaryConfig) {
secondaryConfig->setBranch((int)renderMethod);
}
});
}

Expand All @@ -125,13 +132,14 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const {
}

void recursivelyUpdateLightingModel(const QString& parentTaskName, std::function<void(MakeLightingModelConfig *)> updateLambda, int depth = -1) {
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
if (depth == -1) {
auto secondaryLightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
if (secondaryLightingModelConfig) {
updateLambda(secondaryLightingModelConfig);
}

auto mainLightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
auto mainLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
if (mainLightingModelConfig) {
updateLambda(mainLightingModelConfig);
}
Expand All @@ -143,7 +151,7 @@ void recursivelyUpdateLightingModel(const QString& parentTaskName, std::function

for (size_t mirrorIndex = 0; mirrorIndex < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; mirrorIndex++) {
std::string mirrorTaskString = parentTaskName.toStdString() + ".RenderMirrorView" + std::to_string(mirrorIndex) + "Depth" + std::to_string(depth);
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>(mirrorTaskString + ".LightingModel");
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>(mirrorTaskString + ".LightingModel");
if (lightingModelConfig) {
updateLambda(lightingModelConfig);
recursivelyUpdateLightingModel(QString::fromStdString(mirrorTaskString), updateLambda, depth + 1);
Expand All @@ -166,7 +174,6 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) {
_renderSettingLock.withWriteLock([&] {
_shadowsEnabled = (enabled);
_shadowsEnabledSetting.set(enabled);

Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);

recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setShadow(enabled); });
Expand Down Expand Up @@ -228,7 +235,6 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) {
_renderSettingLock.withWriteLock([&] {
_ambientOcclusionEnabled = (enabled);
_ambientOcclusionEnabledSetting.set(enabled);

Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);

recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setAmbientOcclusion(enabled); });
Expand Down Expand Up @@ -256,52 +262,53 @@ void RenderScriptingInterface::forceProceduralMaterialsEnabled(bool enabled) {
});
}

AntialiasingConfig::Mode RenderScriptingInterface::getAntialiasingMode() const {
AntialiasingSetupConfig::Mode RenderScriptingInterface::getAntialiasingMode() const {
return _antialiasingMode;
}

void RenderScriptingInterface::setAntialiasingMode(AntialiasingConfig::Mode mode) {
void RenderScriptingInterface::setAntialiasingMode(AntialiasingSetupConfig::Mode mode) {
if (_antialiasingMode != mode) {
forceAntialiasingMode(mode);
emit settingsChanged();
}
}

void setAntialiasingModeForView(AntialiasingConfig::Mode mode, JitterSampleConfig *jitterCamConfig, AntialiasingConfig *antialiasingConfig) {
void setAntialiasingModeForView(AntialiasingSetupConfig::Mode mode, AntialiasingSetupConfig *antialiasingSetupConfig, AntialiasingConfig *antialiasingConfig) {
switch (mode) {
case AntialiasingConfig::Mode::NONE:
jitterCamConfig->none();
case AntialiasingSetupConfig::Mode::NONE:
antialiasingSetupConfig->none();
antialiasingConfig->blend = 1;
antialiasingConfig->setDebugFXAA(false);
break;
case AntialiasingConfig::Mode::TAA:
jitterCamConfig->play();
case AntialiasingSetupConfig::Mode::TAA:
antialiasingSetupConfig->play();
antialiasingConfig->blend = 0.25;
antialiasingConfig->setDebugFXAA(false);
break;
case AntialiasingConfig::Mode::FXAA:
jitterCamConfig->none();
case AntialiasingSetupConfig::Mode::FXAA:
antialiasingSetupConfig->none();
antialiasingConfig->blend = 0.25;
antialiasingConfig->setDebugFXAA(true);
break;
default:
jitterCamConfig->none();
antialiasingSetupConfig->none();
antialiasingConfig->blend = 1;
antialiasingConfig->setDebugFXAA(false);
break;
}
}

void recursivelyUpdateAntialiasingMode(const QString& parentTaskName, AntialiasingConfig::Mode mode, int depth = -1) {
void recursivelyUpdateAntialiasingMode(const QString& parentTaskName, AntialiasingSetupConfig::Mode mode, int depth = -1) {
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
if (depth == -1) {
auto secondViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderSecondView.JitterCam");
auto secondViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderSecondView.Antialiasing");
auto secondViewJitterCamConfig = renderConfig->getConfig<AntialiasingSetup>("RenderSecondView.AntialiasingSetup");
auto secondViewAntialiasingConfig = renderConfig->getConfig<Antialiasing>("RenderSecondView.Antialiasing");
if (secondViewJitterCamConfig && secondViewAntialiasingConfig) {
setAntialiasingModeForView(mode, secondViewJitterCamConfig, secondViewAntialiasingConfig);
}

auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
auto mainViewJitterCamConfig = renderConfig->getConfig<AntialiasingSetup>("RenderMainView.AntialiasingSetup");
auto mainViewAntialiasingConfig = renderConfig->getConfig<Antialiasing>("RenderMainView.Antialiasing");
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
setAntialiasingModeForView( mode, mainViewJitterCamConfig, mainViewAntialiasingConfig);
}
Expand All @@ -313,23 +320,23 @@ void recursivelyUpdateAntialiasingMode(const QString& parentTaskName, Antialiasi

for (size_t mirrorIndex = 0; mirrorIndex < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; mirrorIndex++) {
std::string mirrorTaskString = parentTaskName.toStdString() + ".RenderMirrorView" + std::to_string(mirrorIndex) + "Depth" + std::to_string(depth);
auto jitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>(mirrorTaskString + ".JitterCam");
auto antialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>(mirrorTaskString + ".Antialiasing");
auto jitterCamConfig = renderConfig->getConfig<AntialiasingSetup>(mirrorTaskString + ".AntialiasingSetup");
auto antialiasingConfig = renderConfig->getConfig<Antialiasing>(mirrorTaskString + ".Antialiasing");
if (jitterCamConfig && antialiasingConfig) {
setAntialiasingModeForView(mode, jitterCamConfig, antialiasingConfig);
recursivelyUpdateAntialiasingMode(QString::fromStdString(mirrorTaskString), mode, depth + 1);
}
}
}

void RenderScriptingInterface::forceAntialiasingMode(AntialiasingConfig::Mode mode) {
if ((int)mode < 0 || mode >= AntialiasingConfig::Mode::MODE_COUNT) {
mode = AntialiasingConfig::Mode::NONE;
void RenderScriptingInterface::forceAntialiasingMode(AntialiasingSetupConfig::Mode mode) {
if ((int)mode < 0 || mode >= AntialiasingSetupConfig::Mode::MODE_COUNT) {
mode = AntialiasingSetupConfig::Mode::NONE;
}

_renderSettingLock.withWriteLock([&] {
_antialiasingMode = mode;
_antialiasingModeSetting.set(_antialiasingMode);
_antialiasingModeSetting.set((int)_antialiasingMode);

recursivelyUpdateAntialiasingMode("", _antialiasingMode);
});
Expand Down Expand Up @@ -393,20 +400,27 @@ void RenderScriptingInterface::forceViewportResolutionScale(float scale) {
return;
}
_renderSettingLock.withWriteLock([&] {
_viewportResolutionScale = (scale);
_viewportResolutionScale = scale;
_viewportResolutionScaleSetting.set(scale);

auto renderConfig = qApp->getRenderEngine()->getConfiguration();
assert(renderConfig);
auto deferredView = renderConfig->getConfig("RenderMainView.RenderDeferredTask");
// mainView can be null if we're rendering in forward mode
if (deferredView) {
deferredView->setProperty("resolutionScale", _viewportResolutionScale);
deferredView->setProperty("resolutionScale", scale);
}
auto forwardView = renderConfig->getConfig("RenderMainView.RenderForwardTask");
// mainView can be null if we're rendering in forward mode
if (forwardView) {
forwardView->setProperty("resolutionScale", _viewportResolutionScale);
forwardView->setProperty("resolutionScale", scale);
}

auto deferredSecondView = renderConfig->getConfig("RenderSecondView.RenderDeferredTask");
if (deferredSecondView) {
deferredSecondView->setProperty("resolutionScale", scale);
}
auto forwardSecondView = renderConfig->getConfig("RenderSecondView.RenderForwardTask");
if (forwardSecondView) {
forwardSecondView->setProperty("resolutionScale", scale);
}
});
}
Loading
Loading