History

more graphics options

HifiExperiments committed 2 years ago

Commit d4ca3d51 parent 3dad0f16 files · +245 −52Browse files

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

Unified · Split

interface/src/scripting/RenderScriptingInterface.cpp+95−15
@@ -16,6 +16,8 @@ · 15 unmodified lines
16#include <QScreen>16#include <QScreen>
17#include "ScreenName.h"17#include "ScreenName.h"
18 18
19#include <MeshPartPayload.h>
20
19STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){21STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
20 auto scriptEngine = manager->engine().get();22 auto scriptEngine = manager->engine().get();
21 23
@@ -43,16 +45,17 @@ RenderScriptingInterface::RenderScriptingInterface() { · 21 unmodified lines
43 });45 });
44}46}
45 47
46
47void RenderScriptingInterface::loadSettings() {48void RenderScriptingInterface::loadSettings() {
48 _renderSettingLock.withReadLock([&] {49 _renderSettingLock.withReadLock([&] {
49 _renderMethod = (_renderMethodSetting.get());50 _renderMethod = _renderMethodSetting.get();
50 _shadowsEnabled = (_shadowsEnabledSetting.get());51 _shadowsEnabled = _shadowsEnabledSetting.get();
51 _ambientOcclusionEnabled = (_ambientOcclusionEnabledSetting.get());52 _hazeEnabled = _hazeEnabledSetting.get();
52 //_antialiasingMode = (_antialiasingModeSetting.get());53 _bloomEnabled = _bloomEnabledSetting.get();
54 _ambientOcclusionEnabled = _ambientOcclusionEnabledSetting.get();
55 _proceduralMaterialsEnabled = _proceduralMaterialsEnabledSetting.get();
53 _antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());56 _antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());
54 _viewportResolutionScale = (_viewportResolutionScaleSetting.get());57 _viewportResolutionScale = _viewportResolutionScaleSetting.get();
55 _fullScreenScreen = (_fullScreenScreenSetting.get());58 _fullScreenScreen = _fullScreenScreenSetting.get();
56 });59 });
57 60
58 // If full screen screen is not initialized, or set to an invalid value,61 // If full screen screen is not initialized, or set to an invalid value,
@@ -65,7 +68,10 @@ void RenderScriptingInterface::loadSettings() { · 6 unmodified lines
65 68
66 forceRenderMethod((RenderMethod)_renderMethod);69 forceRenderMethod((RenderMethod)_renderMethod);
67 forceShadowsEnabled(_shadowsEnabled);70 forceShadowsEnabled(_shadowsEnabled);
71 forceHazeEnabled(_hazeEnabled);
72 forceBloomEnabled(_bloomEnabled);
68 forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);73 forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);
74 forceProceduralMaterialsEnabled(_proceduralMaterialsEnabled);
69 forceAntialiasingMode(_antialiasingMode);75 forceAntialiasingMode(_antialiasingMode);
70 forceViewportResolutionScale(_viewportResolutionScale);76 forceViewportResolutionScale(_viewportResolutionScale);
71}77}
@@ -136,19 +142,76 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) { · 64 unmodified lines
136 142
137 auto renderConfig = qApp->getRenderEngine()->getConfiguration();143 auto renderConfig = qApp->getRenderEngine()->getConfiguration();
138 assert(renderConfig);144 assert(renderConfig);
145 Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
139 auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");146 auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
140 if (lightingModelConfig) {147 if (lightingModelConfig) {
141 Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
142 lightingModelConfig->setShadow(enabled);148 lightingModelConfig->setShadow(enabled);
143 }149 }
144 auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");150 auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
145 if (secondaryLightingModelConfig) {151 if (secondaryLightingModelConfig) {
146 Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
147 secondaryLightingModelConfig->setShadow(enabled);152 secondaryLightingModelConfig->setShadow(enabled);
148 }153 }
149 });154 });
150}155}
151 156
157bool RenderScriptingInterface::getHazeEnabled() const {
158 return _hazeEnabled;
159}
160
161void RenderScriptingInterface::setHazeEnabled(bool enabled) {
162 if (_hazeEnabled != enabled) {
163 forceHazeEnabled(enabled);
164 emit settingsChanged();
165 }
166}
167
168void RenderScriptingInterface::forceHazeEnabled(bool enabled) {
169 _renderSettingLock.withWriteLock([&] {
170 _hazeEnabled = (enabled);
171 _hazeEnabledSetting.set(enabled);
172
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 }
183 });
184}
185
186bool RenderScriptingInterface::getBloomEnabled() const {
187 return _bloomEnabled;
188}
189
190void RenderScriptingInterface::setBloomEnabled(bool enabled) {
191 if (_bloomEnabled != enabled) {
192 forceBloomEnabled(enabled);
193 emit settingsChanged();
194 }
195}
196
197void RenderScriptingInterface::forceBloomEnabled(bool enabled) {
198 _renderSettingLock.withWriteLock([&] {
199 _bloomEnabled = (enabled);
200 _bloomEnabledSetting.set(enabled);
201
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 });
213}
214
152bool RenderScriptingInterface::getAmbientOcclusionEnabled() const {215bool RenderScriptingInterface::getAmbientOcclusionEnabled() const {
153 return _ambientOcclusionEnabled;216 return _ambientOcclusionEnabled;
154}217}
@@ -165,11 +228,29 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) { · 10 unmodified lines
165 _ambientOcclusionEnabled = (enabled);228 _ambientOcclusionEnabled = (enabled);
166 _ambientOcclusionEnabledSetting.set(enabled);229 _ambientOcclusionEnabledSetting.set(enabled);
167 230
168 auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");231 Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
169 if (lightingModelConfig) {232 ModelMeshPartPayload::enableMaterialProceduralShaders = enabled;
170 Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);233 });
171 lightingModelConfig->setAmbientOcclusion(enabled);234}
172 }235
236bool RenderScriptingInterface::getProceduralMaterialsEnabled() const {
237 return _proceduralMaterialsEnabled;
238}
239
240void RenderScriptingInterface::setProceduralMaterialsEnabled(bool enabled) {
241 if (_proceduralMaterialsEnabled != enabled) {
242 forceProceduralMaterialsEnabled(enabled);
243 emit settingsChanged();
244 }
245}
246
247void RenderScriptingInterface::forceProceduralMaterialsEnabled(bool enabled) {
248 _renderSettingLock.withWriteLock([&] {
249 _proceduralMaterialsEnabled = (enabled);
250 _proceduralMaterialsEnabledSetting.set(enabled);
251
252 Menu::getInstance()->setIsOptionChecked(MenuOption::MaterialProceduralShaders, enabled);
253 ModelMeshPartPayload::enableMaterialProceduralShaders = enabled;
173 });254 });
174}255}
175 256
@@ -233,7 +314,6 @@ void RenderScriptingInterface::forceAntialiasingMode(AntialiasingConfig::Mode mo · 57 unmodified lines
233 });314 });
234}315}
235 316
236
237float RenderScriptingInterface::getViewportResolutionScale() const {317float RenderScriptingInterface::getViewportResolutionScale() const {
238 return _viewportResolutionScale;318 return _viewportResolutionScale;
239}319}