mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 18:42:33 +02:00
Merge pull request #15590 from SamGondelman/settings
BUGZ-284: Add shadows, AA, and AO to RenderScriptingInterface
This commit is contained in:
commit
98e426ac9f
6 changed files with 149 additions and 56 deletions
|
@ -49,16 +49,13 @@
|
|||
#include "DeferredLightingEffect.h"
|
||||
#include "PickManager.h"
|
||||
|
||||
#include "LightingModel.h"
|
||||
#include "AmbientOcclusionEffect.h"
|
||||
#include "RenderShadowTask.h"
|
||||
#include "AntialiasingEffect.h"
|
||||
|
||||
#include "scripting/SettingsScriptingInterface.h"
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
#include "SpeechRecognizer.h"
|
||||
#endif
|
||||
|
||||
#include "scripting/RenderScriptingInterface.h"
|
||||
|
||||
extern bool DEV_DECIMATE_TEXTURES;
|
||||
|
||||
Menu* Menu::getInstance() {
|
||||
|
@ -367,45 +364,14 @@ Menu::Menu() {
|
|||
// Developer > Render >>>
|
||||
MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render");
|
||||
|
||||
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AntiAliasing, 0, true);
|
||||
connect(action, &QAction::triggered, [action] {
|
||||
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
|
||||
if (renderConfig) {
|
||||
auto mainViewJitterCamConfig = renderConfig->getConfig<JitterSample>("RenderMainView.JitterCam");
|
||||
auto mainViewAntialiasingConfig = renderConfig->getConfig<Antialiasing>("RenderMainView.Antialiasing");
|
||||
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
|
||||
if (action->isChecked()) {
|
||||
mainViewJitterCamConfig->play();
|
||||
mainViewAntialiasingConfig->setDebugFXAA(false);
|
||||
} else {
|
||||
mainViewJitterCamConfig->none();
|
||||
mainViewAntialiasingConfig->setDebugFXAA(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AntiAliasing, 0, RenderScriptingInterface::getInstance()->getAntialiasingEnabled(),
|
||||
RenderScriptingInterface::getInstance(), SLOT(setAntialiasingEnabled(bool)));
|
||||
|
||||
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, true);
|
||||
connect(action, &QAction::triggered, [action] {
|
||||
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
|
||||
if (renderConfig) {
|
||||
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||
if (lightingModelConfig) {
|
||||
lightingModelConfig->setShadow(action->isChecked());
|
||||
}
|
||||
}
|
||||
});
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, RenderScriptingInterface::getInstance()->getShadowsEnabled(),
|
||||
RenderScriptingInterface::getInstance(), SLOT(setShadowsEnabled(bool)));
|
||||
|
||||
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AmbientOcclusion, 0, false);
|
||||
connect(action, &QAction::triggered, [action] {
|
||||
auto renderConfig = qApp->getRenderEngine()->getConfiguration();
|
||||
if (renderConfig) {
|
||||
auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||
if (lightingModelConfig) {
|
||||
lightingModelConfig->setAmbientOcclusion(action->isChecked());
|
||||
}
|
||||
}
|
||||
});
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AmbientOcclusion, 0, RenderScriptingInterface::getInstance()->getAmbientOcclusionEnabled(),
|
||||
RenderScriptingInterface::getInstance(), SLOT(setAmbientOcclusionEnabled(bool)));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::WorldAxes);
|
||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DefaultSkybox, 0, true);
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
//
|
||||
#include "RenderScriptingInterface.h"
|
||||
|
||||
#include "LightingModel.h"
|
||||
#include "AntialiasingEffect.h"
|
||||
|
||||
const QString DEFERRED = "deferred";
|
||||
const QString FORWARD = "forward";
|
||||
|
||||
|
@ -17,6 +20,9 @@ RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
|||
|
||||
RenderScriptingInterface::RenderScriptingInterface() {
|
||||
setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD);
|
||||
setShadowsEnabled(_shadowsEnabledSetting.get());
|
||||
setAmbientOcclusionEnabled(_ambientOcclusionEnabledSetting.get());
|
||||
setAntialiasingEnabled(_antialiasingEnabledSetting.get());
|
||||
}
|
||||
|
||||
QString RenderScriptingInterface::getRenderMethod() {
|
||||
|
@ -24,6 +30,11 @@ QString RenderScriptingInterface::getRenderMethod() {
|
|||
}
|
||||
|
||||
void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) {
|
||||
render::Args::RenderMethod newMethod = renderMethod == FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED;
|
||||
if (_renderMethodSetting.get() == newMethod) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod));
|
||||
return;
|
||||
|
@ -31,14 +42,81 @@ void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) {
|
|||
|
||||
auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
|
||||
if (config) {
|
||||
if (renderMethod == DEFERRED) {
|
||||
_renderMethodSetting.set(render::Args::RenderMethod::DEFERRED);
|
||||
config->setBranch(render::Args::RenderMethod::DEFERRED);
|
||||
emit config->dirtyEnabled();
|
||||
} else if (renderMethod == FORWARD) {
|
||||
_renderMethodSetting.set(render::Args::RenderMethod::FORWARD);
|
||||
config->setBranch(render::Args::RenderMethod::FORWARD);
|
||||
emit config->dirtyEnabled();
|
||||
_renderMethodSetting.set(newMethod);
|
||||
config->setBranch(newMethod);
|
||||
emit config->dirtyEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderScriptingInterface::getShadowsEnabled() {
|
||||
return _shadowsEnabledSetting.get();
|
||||
}
|
||||
|
||||
void RenderScriptingInterface::setShadowsEnabled(bool enabled) {
|
||||
if (_shadowsEnabledSetting.get() == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setShadowsEnabled", Q_ARG(bool, enabled));
|
||||
return;
|
||||
}
|
||||
|
||||
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||
if (lightingModelConfig) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::Shadows, enabled);
|
||||
_shadowsEnabledSetting.set(enabled);
|
||||
lightingModelConfig->setShadow(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderScriptingInterface::getAmbientOcclusionEnabled() {
|
||||
return _ambientOcclusionEnabledSetting.get();
|
||||
}
|
||||
|
||||
void RenderScriptingInterface::setAmbientOcclusionEnabled(bool enabled) {
|
||||
if (_ambientOcclusionEnabledSetting.get() == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setAmbientOcclusionEnabled", Q_ARG(bool, enabled));
|
||||
return;
|
||||
}
|
||||
|
||||
auto lightingModelConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<MakeLightingModel>("RenderMainView.LightingModel");
|
||||
if (lightingModelConfig) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::AmbientOcclusion, enabled);
|
||||
_ambientOcclusionEnabledSetting.set(enabled);
|
||||
lightingModelConfig->setAmbientOcclusion(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderScriptingInterface::getAntialiasingEnabled() {
|
||||
return _antialiasingEnabledSetting.get();
|
||||
}
|
||||
|
||||
void RenderScriptingInterface::setAntialiasingEnabled(bool enabled) {
|
||||
if (_antialiasingEnabledSetting.get() == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setAntialiasingEnabled", Q_ARG(bool, enabled));
|
||||
return;
|
||||
}
|
||||
|
||||
auto mainViewJitterCamConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<JitterSample>("RenderMainView.JitterCam");
|
||||
auto mainViewAntialiasingConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<Antialiasing>("RenderMainView.Antialiasing");
|
||||
if (mainViewJitterCamConfig && mainViewAntialiasingConfig) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::AntiAliasing, enabled);
|
||||
_antialiasingEnabledSetting.set(enabled);
|
||||
if (enabled) {
|
||||
mainViewJitterCamConfig->play();
|
||||
mainViewAntialiasingConfig->setDebugFXAA(false);
|
||||
} else {
|
||||
mainViewJitterCamConfig->none();
|
||||
mainViewAntialiasingConfig->setDebugFXAA(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,9 @@
|
|||
class RenderScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString renderMethod READ getRenderMethod WRITE setRenderMethod)
|
||||
Q_PROPERTY(bool shadowsEnabled READ getShadowsEnabled WRITE setShadowsEnabled)
|
||||
Q_PROPERTY(bool ambientOcclusionEnabled READ getAmbientOcclusionEnabled WRITE setAmbientOcclusionEnabled)
|
||||
Q_PROPERTY(bool antialiasingEnabled READ getAntialiasingEnabled WRITE setAntialiasingEnabled)
|
||||
|
||||
public:
|
||||
RenderScriptingInterface();
|
||||
|
@ -37,8 +40,8 @@ public slots:
|
|||
* Get a config for a job by name
|
||||
* @function Render.getConfig
|
||||
* @param {string} name - Can be:
|
||||
* - <job_name>. Search for the first job named job_name traversing the the sub graph of task and jobs (from this task as root)
|
||||
* - <parent_name>.[<sub_parent_names>.]<job_name>. Allows you to first look for the parent_name job (from this task as root) and then search from there for the
|
||||
* - <job_name>: Search for the first job named job_name traversing the the sub graph of task and jobs (from this task as root)
|
||||
* - <parent_name>.[<sub_parent_names>.]<job_name>: Allows you to first look for the parent_name job (from this task as root) and then search from there for the
|
||||
* optional sub_parent_names and finally from there looking for the job_name (assuming every job in the path is found)
|
||||
* @returns {object} The sub job config.
|
||||
*/
|
||||
|
@ -58,8 +61,53 @@ public slots:
|
|||
*/
|
||||
void setRenderMethod(const QString& renderMethod);
|
||||
|
||||
/**jsdoc
|
||||
* Whether or not shadows are enabled
|
||||
* @function Render.getShadowsEnabled
|
||||
* @returns {bool} <code>true</code> if shadows are enabled, otherwise <code>false</code>
|
||||
*/
|
||||
bool getShadowsEnabled();
|
||||
|
||||
/**jsdoc
|
||||
* Enables or disables shadows
|
||||
* @function Render.setShadowsEnabled
|
||||
* @param {bool} enabled - <code>true</code> to enable shadows, <code>false</code> to disable them
|
||||
*/
|
||||
void setShadowsEnabled(bool enabled);
|
||||
|
||||
/**jsdoc
|
||||
* Whether or not ambient occlusion is enabled
|
||||
* @function Render.getAmbientOcclusionEnabled
|
||||
* @returns {bool} <code>true</code> if ambient occlusion is enabled, otherwise <code>false</code>
|
||||
*/
|
||||
bool getAmbientOcclusionEnabled();
|
||||
|
||||
/**jsdoc
|
||||
* Enables or disables ambient occlusion
|
||||
* @function Render.setAmbientOcclusionEnabled
|
||||
* @param {bool} enabled - <code>true</code> to enable ambient occlusion, <code>false</code> to disable it
|
||||
*/
|
||||
void setAmbientOcclusionEnabled(bool enabled);
|
||||
|
||||
/**jsdoc
|
||||
* Whether or not anti-aliasing is enabled
|
||||
* @function Render.getAntialiasingEnabled
|
||||
* @returns {bool} <code>true</code> if anti-aliasing is enabled, otherwise <code>false</code>
|
||||
*/
|
||||
bool getAntialiasingEnabled();
|
||||
|
||||
/**jsdoc
|
||||
* Enables or disables anti-aliasing
|
||||
* @function Render.setAntialiasingEnabled
|
||||
* @param {bool} enabled - <code>true</code> to enable anti-aliasing, <code>false</code> to disable it
|
||||
*/
|
||||
void setAntialiasingEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
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<bool> _antialiasingEnabledSetting { "antialiasingEnabled", true };
|
||||
};
|
||||
|
||||
#endif // hifi_RenderScriptingInterface_h
|
||||
|
|
|
@ -378,6 +378,8 @@ void JitterSample::configure(const Config& config) {
|
|||
}
|
||||
} else if (config.stop) {
|
||||
_sampleSequence.currentIndex = -1;
|
||||
} else {
|
||||
_sampleSequence.currentIndex = config.getIndex();
|
||||
}
|
||||
_scale = config.scale;
|
||||
}
|
||||
|
@ -392,10 +394,10 @@ void JitterSample::run(const render::RenderContextPointer& renderContext, Output
|
|||
}
|
||||
}
|
||||
|
||||
jitter.x = 0.0f;
|
||||
jitter.y = 0.0f;
|
||||
if (current >= 0) {
|
||||
jitter = _sampleSequence.offsets[current];
|
||||
} else {
|
||||
jitter = glm::vec2(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ public:
|
|||
void setDebugFXAA(bool debug) { debugFXAAX = (debug ? 0.0f : 1.0f); emit dirty();}
|
||||
bool debugFXAA() const { return (debugFXAAX == 0.0f ? true : false); }
|
||||
|
||||
|
||||
float blend{ 0.25f };
|
||||
float sharpen{ 0.05f };
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
|
||||
// Debugging task is happening in the "over" layer after tone mapping and just before HUD
|
||||
{ // Debug the bounds of the rendered items, still look at the zbuffer
|
||||
const auto extraDebugBuffers = RenderDeferredTaskDebug::ExtraBuffers(linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, ambientOcclusionFramebuffer, scatteringResource, velocityBuffer);
|
||||
const auto extraDebugBuffers = RenderDeferredTaskDebug::ExtraBuffers(linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, ambientOcclusionUniforms, scatteringResource, velocityBuffer);
|
||||
const auto debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, shadowTaskOutputs, lightingStageInputs, lightClusters, prepareDeferredOutputs, extraDebugBuffers,
|
||||
deferredFrameTransform, jitter, lightingModel).asVarying();
|
||||
task.addJob<RenderDeferredTaskDebug>("DebugRenderDeferredTask", debugInputs);
|
||||
|
|
Loading…
Reference in a new issue