Skip to content

Commit

Permalink
Secondary camera now has the same antialiasing settings as main one
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuprynowicz committed Dec 24, 2022
1 parent 2b0626e commit 00a2880
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
59 changes: 36 additions & 23 deletions interface/src/scripting/RenderScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,36 +132,49 @@ void RenderScriptingInterface::setAntialiasingMode(AntialiasingConfig::Mode mode
}
}

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

void RenderScriptingInterface::forceAntialiasingMode(AntialiasingConfig::Mode mode) {
_renderSettingLock.withWriteLock([&] {
_antialiasingMode = mode;

auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
auto secondViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderSecondView.JitterCam");
auto secondViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderSecondView.Antialiasing");
if (mode != AntialiasingConfig::Mode::NONE
&& mode != AntialiasingConfig::Mode::TAA
&& mode != AntialiasingConfig::Mode::FXAA) {
_antialiasingMode = AntialiasingConfig::Mode::NONE;
}
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
switch (mode) {
case AntialiasingConfig::Mode::NONE:
mainViewJitterCamConfig->none();
mainViewAntialiasingConfig->blend = 1;
mainViewAntialiasingConfig->setDebugFXAA(false);
break;
case AntialiasingConfig::Mode::TAA:
mainViewJitterCamConfig->play();
mainViewAntialiasingConfig->blend = 0.25;
mainViewAntialiasingConfig->setDebugFXAA(false);
break;
case AntialiasingConfig::Mode::FXAA:
mainViewJitterCamConfig->none();
mainViewAntialiasingConfig->blend = 0.25;
mainViewAntialiasingConfig->setDebugFXAA(true);
break;
default:
_antialiasingMode = AntialiasingConfig::Mode::NONE;
mainViewJitterCamConfig->none();
mainViewAntialiasingConfig->blend = 1;
mainViewAntialiasingConfig->setDebugFXAA(false);
break;
}
setAntialiasingModeForView( mode, mainViewJitterCamConfig, mainViewAntialiasingConfig);
}
if (secondViewJitterCamConfig && secondViewAntialiasingConfig) {
setAntialiasingModeForView( mode, secondViewJitterCamConfig, secondViewAntialiasingConfig);
}

_antialiasingModeSetting.set(_antialiasingMode);
Expand Down
4 changes: 2 additions & 2 deletions interface/src/scripting/RenderScriptingInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ public slots:
int _renderMethod{ RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
bool _shadowsEnabled{ true };
bool _ambientOcclusionEnabled{ false };
AntialiasingConfig::Mode _antialiasingMode{ AntialiasingConfig::Mode::TAA };
AntialiasingConfig::Mode _antialiasingMode{ AntialiasingConfig::Mode::NONE };
float _viewportResolutionScale{ 1.0f };

// Actual settings saved on disk
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
Setting::Handle<bool> _shadowsEnabledSetting { "shadowsEnabled", true };
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", false };
//Setting::Handle<AntialiasingConfig::Mode> _antialiasingModeSetting { "antialiasingMode", AntialiasingConfig::Mode::TAA };
Setting::Handle<int> _antialiasingModeSetting { "antialiasingMode", AntialiasingConfig::Mode::TAA };
Setting::Handle<int> _antialiasingModeSetting { "antialiasingMode", AntialiasingConfig::Mode::NONE };
Setting::Handle<float> _viewportResolutionScaleSetting { "viewportResolutionScale", 1.0f };

// Force assign both setting AND runtime value to the parameter value
Expand Down

0 comments on commit 00a2880

Please sign in to comment.