History

fix AO setting + effects in mirrors

HifiExperiments committed 2 years ago

Commit 25945831 parent d4ca3d51 file · +33 −31Browse files

Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/scripting/RenderScriptingInterface.cpp+33−31
@@ -124,6 +124,33 @@ QStringList RenderScriptingInterface::getRenderMethodNames() const { · 123 unmodified lines
124124 return refrenderMethodNames;
125125 }
126126
127+void recursivelyUpdateLightingModel(const QString& parentTaskName, std::function<void(MakeLightingModelConfig *)> updateLambda, int depth = -1) {
128+ if (depth == -1) {
129+ auto secondaryLightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
130+ if (secondaryLightingModelConfig) {
131+ updateLambda(secondaryLightingModelConfig);
132+ }
133+
134+ auto mainLightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
135+ if (mainLightingModelConfig) {
136+ updateLambda(mainLightingModelConfig);
137+ }
138+
139+ recursivelyUpdateLightingModel("RenderMainView", updateLambda, depth + 1);
140+ } else if (depth == RenderMirrorTask::MAX_MIRROR_DEPTH) {
141+ return;
142+ }
143+
144+ for (size_t mirrorIndex = 0; mirrorIndex < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; mirrorIndex++) {
145+ std::string mirrorTaskString = parentTaskName.toStdString() + ".RenderMirrorView" + std::to_string(mirrorIndex) + "Depth" + std::to_string(depth);
146+ auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>(mirrorTaskString + ".LightingModel");
147+ if (lightingModelConfig) {
148+ updateLambda(lightingModelConfig);
149+ recursivelyUpdateLightingModel(QString::fromStdString(mirrorTaskString), updateLambda, depth + 1);
150+ }
151+ }
152+}
153+
127154 bool RenderScriptingInterface::getShadowsEnabled() const {
128155 return _shadowsEnabled;
129156 }
@@ -140,17 +167,9 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { · 10 unmodified lines
140167 _shadowsEnabled = (enabled);
141168 _shadowsEnabledSetting.set(enabled);
142169
143− auto renderConfig = qApp->getRenderEngine()->getConfiguration();
144− assert(renderConfig);
145170 Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
146− auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
147− if (lightingModelConfig) {
148− lightingModelConfig->setShadow(enabled);
149− }
150− auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
151− if (secondaryLightingModelConfig) {
152− secondaryLightingModelConfig->setShadow(enabled);
153− }
171+
172+ recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setShadow(enabled); });
154173 });
155174 }
156175
@@ -170,16 +189,7 @@ void RenderScriptingInterface::forceHazeEnabled(bool enabled) { · 13 unmodified lines
170189 _hazeEnabled = (enabled);
171190 _hazeEnabledSetting.set(enabled);
172191
173− auto renderConfig = qApp->getRenderEngine()->getConfiguration();
174− assert(renderConfig);
175− auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
176− if (lightingModelConfig) {
177− lightingModelConfig->setHaze(enabled);
178− }
179− auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
180− if (secondaryLightingModelConfig) {
181− secondaryLightingModelConfig->setHaze(enabled);
182− }
192+ recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setHaze(enabled); });
183193 });
184194 }
185195
@@ -199,16 +209,7 @@ void RenderScriptingInterface::forceBloomEnabled(bool enabled) { · 13 unmodified lines
199209 _bloomEnabled = (enabled);
200210 _bloomEnabledSetting.set(enabled);
201211
202− auto renderConfig = qApp->getRenderEngine()->getConfiguration();
203− assert(renderConfig);
204− auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
205− if (lightingModelConfig) {
206− lightingModelConfig->setBloom(enabled);
207− }
208− auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
209− if (secondaryLightingModelConfig) {
210− secondaryLightingModelConfig->setBloom(enabled);
211− }
212+ recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setBloom(enabled); });
212213 });
213214 }
214215
@@ -229,7 +230,8 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { · 14 unmodified lines
229230 _ambientOcclusionEnabledSetting.set(enabled);
230231
231232 Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
232− ModelMeshPartPayload::enableMaterialProceduralShaders = enabled;
233+
234+ recursivelyUpdateLightingModel("", [enabled] (MakeLightingModelConfig *config) { config->setAmbientOcclusion(enabled); });
233235 });
234236 }
235237