more graphics options

This commit is contained in:
HifiExperiments 2024-06-28 14:50:25 -07:00
parent 3dad0f14a2
commit d4ca3d5dc1
6 changed files with 254 additions and 61 deletions

View file

@ -212,8 +212,8 @@ Flickable {
ColumnLayout {
anchors.left: renderingEffectsHeader.right
anchors.leftMargin: 20
Layout.preferredWidth: parent.width
spacing: 0
Layout.preferredWidth: parent.width
spacing: 0
enabled: performanceCustom.checked
HifiControlsUit.RadioButton {
@ -267,6 +267,45 @@ Flickable {
Render.shadowsEnabled = renderingEffectShadows.checked;
}
}
HifiControlsUit.CheckBox {
id: renderingEffectFog
checked: Render.hazeEnabled
boxSize: 16
text: "Fog"
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectShadows.bottom
onCheckedChanged: {
Render.hazeEnabled = renderingEffectFog.checked;
}
}
HifiControlsUit.CheckBox {
id: renderingEffectBloom
checked: Render.bloomEnabled
boxSize: 16
text: "Bloom"
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectFog.bottom
onCheckedChanged: {
Render.bloomEnabled = renderingEffectBloom.checked;
}
}
HifiControlsUit.CheckBox {
id: renderingEffectAO
checked: Render.ambientOcclusionEnabled
boxSize: 16
text: "AO"
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectBloom.bottom
onCheckedChanged: {
Render.ambientOcclusionEnabled = renderingEffectAO.checked;
}
}
HifiControlsUit.CheckBox {
id: renderingEffectLocalLights
enabled: false
@ -277,41 +316,11 @@ Flickable {
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectShadows.bottom
anchors.top: renderingEffectAO.bottom
//onCheckedChanged: {
// Render.localLightsEnabled = renderingEffectLocalLightsEnabled.checked;
//}
}
HifiControlsUit.CheckBox {
id: renderingEffectFog
enabled: false
//checked: Render.fogEnabled
checked: renderingEffectsEnabled.checked
boxSize: 16
text: "Fog"
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectLocalLights.bottom
//onCheckedChanged: {
// Render.fogEnabled = renderingEffectFogEnabled.checked;
//}
}
HifiControlsUit.CheckBox {
id: renderingEffectBloom
enabled: false
//checked: Render.bloomEnabled
checked: renderingEffectsEnabled.checked
boxSize: 16
text: "Bloom"
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: parent.left
anchors.top: renderingEffectFog.bottom
//onCheckedChanged: {
// Render.bloomEnabled = renderingEffectBloomEnabled.checked;
//}
}
}
}
}
@ -811,6 +820,42 @@ Flickable {
}
}
ColumnLayout {
Layout.topMargin: 20
Layout.preferredWidth: parent.width
spacing: 0
Item {
Layout.preferredWidth: parent.width
Layout.preferredHeight: 35
HifiStylesUit.RalewayRegular {
id: proceduralMaterialsHeader
text: "Procedural Materials"
anchors.left: parent.left
anchors.top: parent.top
width: 130
height: parent.height
size: 16
color: "#FFFFFF"
}
HifiControlsUit.CheckBox {
id: renderingEffectProceduralMaterials
checked: Render.proceduralMaterialsEnabled
boxSize: 16
spacing: -1
colorScheme: hifi.colorSchemes.dark
anchors.left: proceduralMaterialsHeader.right
anchors.leftMargin: 20
anchors.top: parent.top
onCheckedChanged: {
Render.proceduralMaterialsEnabled = renderingEffectProceduralMaterials.checked;
}
}
}
}
}
}

View file

@ -538,10 +538,8 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ComputeBlendshapes, 0, true,
DependencyManager::get<ModelBlender>().data(), SLOT(setComputeBlendshapes(bool)));
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::MaterialProceduralShaders, 0, false);
connect(action, &QAction::triggered, [action] {
ModelMeshPartPayload::enableMaterialProceduralShaders = action->isChecked();
});
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::MaterialProceduralShaders, 0, RenderScriptingInterface::getInstance()->getProceduralMaterialsEnabled(),
RenderScriptingInterface::getInstance(), SLOT(setProceduralMaterialsEnabled(bool)));
{
auto drawStatusConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<render::DrawStatus>("RenderMainView.DrawStatus");

View file

@ -95,11 +95,13 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP
RenderScriptingInterface::RenderMethod::DEFERRED :
RenderScriptingInterface::RenderMethod::FORWARD ) );
RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommendedPpiScale);
RenderScriptingInterface::getInstance()->setShadowsEnabled(true);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
RenderScriptingInterface::getInstance()->setHazeEnabled(true);
RenderScriptingInterface::getInstance()->setBloomEnabled(true);
RenderScriptingInterface::getInstance()->setAmbientOcclusionEnabled(true);
RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommendedPpiScale);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
DependencyManager::get<LODManager>()->setWorldDetailQuality(WORLD_DETAIL_MEDIUM);
break;
@ -108,30 +110,39 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP
RenderScriptingInterface::RenderMethod::DEFERRED :
RenderScriptingInterface::RenderMethod::FORWARD));
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
RenderScriptingInterface::getInstance()->setHazeEnabled(true);
RenderScriptingInterface::getInstance()->setBloomEnabled(true);
RenderScriptingInterface::getInstance()->setAmbientOcclusionEnabled(false);
RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommendedPpiScale);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
DependencyManager::get<LODManager>()->setWorldDetailQuality(WORLD_DETAIL_MEDIUM);
break;
case PerformancePreset::LOW:
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::FORWARD);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
RenderScriptingInterface::getInstance()->setHazeEnabled(true);
RenderScriptingInterface::getInstance()->setBloomEnabled(false);
RenderScriptingInterface::getInstance()->setAmbientOcclusionEnabled(false);
RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommendedPpiScale);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME);
DependencyManager::get<LODManager>()->setWorldDetailQuality(WORLD_DETAIL_LOW);
break;
case PerformancePreset::LOW_POWER:
RenderScriptingInterface::getInstance()->setRenderMethod(RenderScriptingInterface::RenderMethod::FORWARD);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO);
RenderScriptingInterface::getInstance()->setShadowsEnabled(false);
RenderScriptingInterface::getInstance()->setHazeEnabled(false);
RenderScriptingInterface::getInstance()->setBloomEnabled(false);
RenderScriptingInterface::getInstance()->setAmbientOcclusionEnabled(false);
RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommendedPpiScale);
qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::ECO);
DependencyManager::get<LODManager>()->setWorldDetailQuality(WORLD_DETAIL_LOW);
break;

View file

@ -16,6 +16,8 @@
#include <QScreen>
#include "ScreenName.h"
#include <MeshPartPayload.h>
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
auto scriptEngine = manager->engine().get();
@ -43,16 +45,17 @@ RenderScriptingInterface::RenderScriptingInterface() {
});
}
void RenderScriptingInterface::loadSettings() {
_renderSettingLock.withReadLock([&] {
_renderMethod = (_renderMethodSetting.get());
_shadowsEnabled = (_shadowsEnabledSetting.get());
_ambientOcclusionEnabled = (_ambientOcclusionEnabledSetting.get());
//_antialiasingMode = (_antialiasingModeSetting.get());
_renderMethod = _renderMethodSetting.get();
_shadowsEnabled = _shadowsEnabledSetting.get();
_hazeEnabled = _hazeEnabledSetting.get();
_bloomEnabled = _bloomEnabledSetting.get();
_ambientOcclusionEnabled = _ambientOcclusionEnabledSetting.get();
_proceduralMaterialsEnabled = _proceduralMaterialsEnabledSetting.get();
_antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());
_viewportResolutionScale = (_viewportResolutionScaleSetting.get());
_fullScreenScreen = (_fullScreenScreenSetting.get());
_viewportResolutionScale = _viewportResolutionScaleSetting.get();
_fullScreenScreen = _fullScreenScreenSetting.get();
});
// If full screen screen is not initialized, or set to an invalid value,
@ -65,7 +68,10 @@ void RenderScriptingInterface::loadSettings() {
forceRenderMethod((RenderMethod)_renderMethod);
forceShadowsEnabled(_shadowsEnabled);
forceHazeEnabled(_hazeEnabled);
forceBloomEnabled(_bloomEnabled);
forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);
forceProceduralMaterialsEnabled(_proceduralMaterialsEnabled);
forceAntialiasingMode(_antialiasingMode);
forceViewportResolutionScale(_viewportResolutionScale);
}
@ -136,19 +142,76 @@ void RenderScriptingInterface::forceShadowsEnabled(bool enabled) {
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
assert(renderConfig);
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
if (lightingModelConfig) {
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
lightingModelConfig->setShadow(enabled);
}
auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
if (secondaryLightingModelConfig) {
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
secondaryLightingModelConfig->setShadow(enabled);
}
});
}
bool RenderScriptingInterface::getHazeEnabled() const {
return _hazeEnabled;
}
void RenderScriptingInterface::setHazeEnabled(bool enabled) {
if (_hazeEnabled != enabled) {
forceHazeEnabled(enabled);
emit settingsChanged();
}
}
void RenderScriptingInterface::forceHazeEnabled(bool enabled) {
_renderSettingLock.withWriteLock([&] {
_hazeEnabled = (enabled);
_hazeEnabledSetting.set(enabled);
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
assert(renderConfig);
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
if (lightingModelConfig) {
lightingModelConfig->setHaze(enabled);
}
auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
if (secondaryLightingModelConfig) {
secondaryLightingModelConfig->setHaze(enabled);
}
});
}
bool RenderScriptingInterface::getBloomEnabled() const {
return _bloomEnabled;
}
void RenderScriptingInterface::setBloomEnabled(bool enabled) {
if (_bloomEnabled != enabled) {
forceBloomEnabled(enabled);
emit settingsChanged();
}
}
void RenderScriptingInterface::forceBloomEnabled(bool enabled) {
_renderSettingLock.withWriteLock([&] {
_bloomEnabled = (enabled);
_bloomEnabledSetting.set(enabled);
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
assert(renderConfig);
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
if (lightingModelConfig) {
lightingModelConfig->setBloom(enabled);
}
auto secondaryLightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderSecondView.LightingModel");
if (secondaryLightingModelConfig) {
secondaryLightingModelConfig->setBloom(enabled);
}
});
}
bool RenderScriptingInterface::getAmbientOcclusionEnabled() const {
return _ambientOcclusionEnabled;
}
@ -165,11 +228,29 @@ void RenderScriptingInterface::forceAmbientOcclusionEnabled(bool enabled) {
_ambientOcclusionEnabled = (enabled);
_ambientOcclusionEnabledSetting.set(enabled);
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
if (lightingModelConfig) {
Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
lightingModelConfig->setAmbientOcclusion(enabled);
}
Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
ModelMeshPartPayload::enableMaterialProceduralShaders = enabled;
});
}
bool RenderScriptingInterface::getProceduralMaterialsEnabled() const {
return _proceduralMaterialsEnabled;
}
void RenderScriptingInterface::setProceduralMaterialsEnabled(bool enabled) {
if (_proceduralMaterialsEnabled != enabled) {
forceProceduralMaterialsEnabled(enabled);
emit settingsChanged();
}
}
void RenderScriptingInterface::forceProceduralMaterialsEnabled(bool enabled) {
_renderSettingLock.withWriteLock([&] {
_proceduralMaterialsEnabled = (enabled);
_proceduralMaterialsEnabledSetting.set(enabled);
Menu::getInstance()->setIsOptionChecked(MenuOption::MaterialProceduralShaders, enabled);
ModelMeshPartPayload::enableMaterialProceduralShaders = enabled;
});
}
@ -233,7 +314,6 @@ void RenderScriptingInterface::forceAntialiasingMode(AntialiasingConfig::Mode mo
});
}
float RenderScriptingInterface::getViewportResolutionScale() const {
return _viewportResolutionScale;
}

View file

@ -29,8 +29,12 @@
*
* @property {Render.RenderMethod} renderMethod - The render method being used.
* @property {boolean} shadowsEnabled - <code>true</code> if shadows are enabled, <code>false</code> if they're disabled.
* @property {boolean} hazeEnabled - <code>true</code> if haze (fog) is enabled, <code>false</code> if it's disabled.
* @property {boolean} bloomEnabled - <code>true</code> if bloom is enabled, <code>false</code> if it's disabled.
* @property {boolean} ambientOcclusionEnabled - <code>true</code> if ambient occlusion is enabled, <code>false</code> if it's
* disabled.
* @property {boolean} proceduralMaterialsEnabled - <code>true</code> if procedural shaders are enabled, <code>false</code> if
* they're disabled.
* @property {integer} antialiasingMode - The active anti-aliasing mode.
* @property {number} viewportResolutionScale - The view port resolution scale, <code>&gt; 0.0</code>.
*/
@ -38,7 +42,10 @@ class RenderScriptingInterface : public QObject {
Q_OBJECT
Q_PROPERTY(RenderMethod renderMethod READ getRenderMethod WRITE setRenderMethod NOTIFY settingsChanged)
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled NOTIFY settingsChanged)
Q_PROPERTY(bool hazeEnabled READ getHazeEnabled WRITE setHazeEnabled NOTIFY settingsChanged)
Q_PROPERTY(bool bloomEnabled READ getBloomEnabled WRITE setBloomEnabled NOTIFY settingsChanged)
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled NOTIFY settingsChanged)
Q_PROPERTY(bool proceduralMaterialsEnabled READ getProceduralMaterialsEnabled WRITE setProceduralMaterialsEnabled NOTIFY settingsChanged)
Q_PROPERTY(AntialiasingConfig::Mode antialiasingMode READ getAntialiasingMode WRITE setAntialiasingMode NOTIFY settingsChanged)
Q_PROPERTY(float viewportResolutionScale READ getViewportResolutionScale WRITE setViewportResolutionScale NOTIFY settingsChanged)
Q_PROPERTY(float verticalFieldOfView READ getVerticalFieldOfView WRITE setVerticalFieldOfView NOTIFY settingsChanged)
@ -134,6 +141,34 @@ public slots:
*/
void setShadowsEnabled(bool enabled);
/*@jsdoc
* Gets whether or not haze is enabled.
* @function Render.getHazeEnabled
* @returns {boolean} <code>true</code> if haze is enabled, <code>false</code> if it's disabled.
*/
bool getHazeEnabled() const;
/*@jsdoc
* Sets whether or not haze is enabled.
* @function Render.setHazeEnabled
* @param {boolean} enabled - <code>true</code> to enable haze, <code>false</code> to disable.
*/
void setHazeEnabled(bool enabled);
/*@jsdoc
* Gets whether or not bloom is enabled.
* @function Render.getBloomEnabled
* @returns {boolean} <code>true</code> if bloom is enabled, <code>false</code> if it's disabled.
*/
bool getBloomEnabled() const;
/*@jsdoc
* Sets whether or not bloom is enabled.
* @function Render.setBloomEnabled
* @param {boolean} enabled - <code>true</code> to enable bloom, <code>false</code> to disable.
*/
void setBloomEnabled(bool enabled);
/*@jsdoc
* Gets whether or not ambient occlusion is enabled.
* @function Render.getAmbientOcclusionEnabled
@ -148,6 +183,20 @@ public slots:
*/
void setAmbientOcclusionEnabled(bool enabled);
/*@jsdoc
* Gets whether or not procedural materials are enabled.
* @function Render.getProceduralMaterialsEnabled
* @returns {boolean} <code>true</code> if procedural materials are enabled, <code>false</code> if they're disabled.
*/
bool getProceduralMaterialsEnabled() const;
/*@jsdoc
* Sets whether or not procedural materials are enabled.
* @function Render.setProceduralMaterialsEnabled
* @param {boolean} enabled - <code>true</code> to enable procedural materials, <code>false</code> to disable.
*/
void setProceduralMaterialsEnabled(bool enabled);
/*@jsdoc
* Gets the active anti-aliasing mode.
* @function Render.getAntialiasingMode
@ -235,7 +284,10 @@ private:
// Runtime value of each settings
int _renderMethod { RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
bool _shadowsEnabled { true };
bool _hazeEnabled { true };
bool _bloomEnabled { true };
bool _ambientOcclusionEnabled { true };
bool _proceduralMaterialsEnabled { true };
AntialiasingConfig::Mode _antialiasingMode { AntialiasingConfig::Mode::NONE };
float _viewportResolutionScale { 1.0f };
QString _fullScreenScreen;
@ -243,8 +295,10 @@ private:
// 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> _hazeEnabledSetting { "hazeEnabled", true };
Setting::Handle<bool> _bloomEnabledSetting { "bloomEnabled", true };
Setting::Handle<bool> _ambientOcclusionEnabledSetting { "ambientOcclusionEnabled", true };
//Setting::Handle<AntialiasingConfig::Mode> _antialiasingModeSetting { "antialiasingMode", AntialiasingConfig::Mode::TAA };
Setting::Handle<bool> _proceduralMaterialsEnabledSetting { "proceduralMaterialsEnabled", true };
Setting::Handle<int> _antialiasingModeSetting { "antialiasingMode", AntialiasingConfig::Mode::NONE };
Setting::Handle<float> _viewportResolutionScaleSetting { "viewportResolutionScale", 1.0f };
Setting::Handle<QString> _fullScreenScreenSetting { "fullScreenScreen", "" };
@ -252,7 +306,10 @@ private:
// Force assign both setting AND runtime value to the parameter value
void forceRenderMethod(RenderMethod renderMethod);
void forceShadowsEnabled(bool enabled);
void forceHazeEnabled(bool enabled);
void forceBloomEnabled(bool enabled);
void forceAmbientOcclusionEnabled(bool enabled);
void forceProceduralMaterialsEnabled(bool enabled);
void forceAntialiasingMode(AntialiasingConfig::Mode mode);
void forceViewportResolutionScale(float scale);

View file

@ -197,6 +197,8 @@ public:
bool isAmbientOcclusionEnabled() const { return enableAmbientOcclusion; }
void setShadow(bool enable) { enableShadow = enable; emit dirty(); }
bool isShadowEnabled() const { return enableShadow; }
void setHaze(bool enable) { enableHaze = enable; emit dirty(); }
void setBloom(bool enable) { enableBloom = enable; emit dirty(); }
signals:
void dirty();