mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Add shadowmap as a debug feature
This commit is contained in:
parent
29945bba92
commit
1b36d56b7a
10 changed files with 62 additions and 23 deletions
|
@ -95,6 +95,7 @@
|
||||||
#include <plugins/PluginContainer.h>
|
#include <plugins/PluginContainer.h>
|
||||||
#include <plugins/PluginManager.h>
|
#include <plugins/PluginManager.h>
|
||||||
#include <RenderableWebEntityItem.h>
|
#include <RenderableWebEntityItem.h>
|
||||||
|
#include <RenderShadowTask.h>
|
||||||
#include <RenderDeferredTask.h>
|
#include <RenderDeferredTask.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
#include <RenderScriptingInterface.h>
|
#include <RenderScriptingInterface.h>
|
||||||
|
@ -672,6 +673,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
initializeGL();
|
initializeGL();
|
||||||
|
|
||||||
// Start rendering
|
// Start rendering
|
||||||
|
_renderEngine->addTask(make_shared<RenderShadowTask>());
|
||||||
_renderEngine->addTask(make_shared<RenderDeferredTask>());
|
_renderEngine->addTask(make_shared<RenderDeferredTask>());
|
||||||
_renderEngine->registerScene(_main3DScene);
|
_renderEngine->registerScene(_main3DScene);
|
||||||
|
|
||||||
|
@ -3825,9 +3827,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
renderContext.setArgs(renderArgs);
|
renderContext.setArgs(renderArgs);
|
||||||
|
|
||||||
bool occlusionStatus = Menu::getInstance()->isOptionChecked(MenuOption::DebugAmbientOcclusion);
|
bool occlusionStatus = Menu::getInstance()->isOptionChecked(MenuOption::DebugAmbientOcclusion);
|
||||||
|
bool shadowStatus = Menu::getInstance()->isOptionChecked(MenuOption::DebugShadows);
|
||||||
bool antialiasingStatus = Menu::getInstance()->isOptionChecked(MenuOption::Antialiasing);
|
bool antialiasingStatus = Menu::getInstance()->isOptionChecked(MenuOption::Antialiasing);
|
||||||
bool showOwnedStatus = Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowOwned);
|
bool showOwnedStatus = Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowOwned);
|
||||||
renderContext.setOptions(occlusionStatus, antialiasingStatus, showOwnedStatus);
|
renderContext.setOptions(occlusionStatus, antialiasingStatus, showOwnedStatus, shadowStatus);
|
||||||
|
|
||||||
_renderEngine->setRenderContext(renderContext);
|
_renderEngine->setRenderContext(renderContext);
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,7 @@ Menu::Menu() {
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere, 0, true);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere, 0, true);
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::WorldAxes);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::WorldAxes);
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DebugAmbientOcclusion);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DebugAmbientOcclusion);
|
||||||
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DebugShadows);
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Antialiasing);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Antialiasing);
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, 0, true);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, 0, true);
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ namespace MenuOption {
|
||||||
const QString CoupleEyelids = "Couple Eyelids";
|
const QString CoupleEyelids = "Couple Eyelids";
|
||||||
const QString CrashInterface = "Crash Interface";
|
const QString CrashInterface = "Crash Interface";
|
||||||
const QString DebugAmbientOcclusion = "Debug Ambient Occlusion";
|
const QString DebugAmbientOcclusion = "Debug Ambient Occlusion";
|
||||||
|
const QString DebugShadows = "Debug Shadows";
|
||||||
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
||||||
const QString DeleteBookmark = "Delete Bookmark...";
|
const QString DeleteBookmark = "Delete Bookmark...";
|
||||||
const QString DisableActivityLogger = "Disable Activity Logger";
|
const QString DisableActivityLogger = "Disable Activity Logger";
|
||||||
|
|
|
@ -56,14 +56,21 @@ void DeferredLightingEffect::init() {
|
||||||
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
|
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
|
||||||
_directionalSkyboxLightLocations = std::make_shared<LightLocations>();
|
_directionalSkyboxLightLocations = std::make_shared<LightLocations>();
|
||||||
|
|
||||||
|
_directionalLightShadowLocations = std::make_shared<LightLocations>();
|
||||||
|
_directionalAmbientSphereLightShadowLocations = std::make_shared<LightLocations>();
|
||||||
|
_directionalSkyboxLightShadowLocations = std::make_shared<LightLocations>();
|
||||||
|
|
||||||
_pointLightLocations = std::make_shared<LightLocations>();
|
_pointLightLocations = std::make_shared<LightLocations>();
|
||||||
_spotLightLocations = std::make_shared<LightLocations>();
|
_spotLightLocations = std::make_shared<LightLocations>();
|
||||||
|
|
||||||
// TODO: To use shadowmaps, replace directional_*_light_frag with directional_*_light_shadow_frag shaders.
|
|
||||||
loadLightProgram(deferred_light_vert, directional_light_frag, false, _directionalLight, _directionalLightLocations);
|
loadLightProgram(deferred_light_vert, directional_light_frag, false, _directionalLight, _directionalLightLocations);
|
||||||
loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
||||||
loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
||||||
|
|
||||||
|
loadLightProgram(deferred_light_vert, directional_light_shadow_frag, false, _directionalLightShadow, _directionalLightShadowLocations);
|
||||||
|
loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
|
||||||
|
loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
|
||||||
|
|
||||||
loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations);
|
loadLightProgram(deferred_light_limited_vert, point_light_frag, true, _pointLight, _pointLightLocations);
|
||||||
loadLightProgram(deferred_light_spot_vert, spot_light_frag, true, _spotLight, _spotLightLocations);
|
loadLightProgram(deferred_light_spot_vert, spot_light_frag, true, _spotLight, _spotLightLocations);
|
||||||
|
|
||||||
|
@ -289,18 +296,27 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
||||||
{
|
{
|
||||||
bool useSkyboxCubemap = (_skybox) && (_skybox->getCubemap());
|
bool useSkyboxCubemap = (_skybox) && (_skybox->getCubemap());
|
||||||
|
|
||||||
auto& program = _directionalLight;
|
auto& program = _shadowMapStatus ? _directionalLightShadow : _directionalLight;
|
||||||
LightLocationsPtr locations = _directionalLightLocations;
|
LightLocationsPtr locations = _shadowMapStatus ? _directionalLightShadowLocations : _directionalLightLocations;
|
||||||
|
|
||||||
// TODO: At some point bring back the shadows...
|
|
||||||
// Setup the global directional pass pipeline
|
// Setup the global directional pass pipeline
|
||||||
{
|
{
|
||||||
if (useSkyboxCubemap) {
|
if (_shadowMapStatus) {
|
||||||
program = _directionalSkyboxLight;
|
if (useSkyboxCubemap) {
|
||||||
locations = _directionalSkyboxLightLocations;
|
program = _directionalSkyboxLightShadow;
|
||||||
} else if (_ambientLightMode > -1) {
|
locations = _directionalSkyboxLightShadowLocations;
|
||||||
program = _directionalAmbientSphereLight;
|
} else if (_ambientLightMode > -1) {
|
||||||
locations = _directionalAmbientSphereLightLocations;
|
program = _directionalAmbientSphereLightShadow;
|
||||||
|
locations = _directionalAmbientSphereLightShadowLocations;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (useSkyboxCubemap) {
|
||||||
|
program = _directionalSkyboxLight;
|
||||||
|
locations = _directionalSkyboxLightLocations;
|
||||||
|
} else if (_ambientLightMode > -1) {
|
||||||
|
program = _directionalAmbientSphereLight;
|
||||||
|
locations = _directionalAmbientSphereLightLocations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locations->shadowTransformBuffer >= 0) {
|
if (locations->shadowTransformBuffer >= 0) {
|
||||||
|
|
|
@ -53,27 +53,37 @@ public:
|
||||||
void setGlobalSkybox(const model::SkyboxPointer& skybox);
|
void setGlobalSkybox(const model::SkyboxPointer& skybox);
|
||||||
|
|
||||||
const LightStage& getLightStage() { return _lightStage; }
|
const LightStage& getLightStage() { return _lightStage; }
|
||||||
|
void setShadowMapStatus(bool enable) { _shadowMapStatus = enable; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LightStage _lightStage;
|
LightStage _lightStage;
|
||||||
|
bool _shadowMapStatus{ false };
|
||||||
|
|
||||||
DeferredLightingEffect() = default;
|
DeferredLightingEffect() = default;
|
||||||
|
|
||||||
model::MeshPointer _spotLightMesh;
|
model::MeshPointer _spotLightMesh;
|
||||||
model::MeshPointer getSpotLightMesh();
|
model::MeshPointer getSpotLightMesh();
|
||||||
|
|
||||||
gpu::PipelinePointer _directionalSkyboxLight;
|
gpu::PipelinePointer _directionalSkyboxLight;
|
||||||
LightLocationsPtr _directionalSkyboxLightLocations;
|
|
||||||
|
|
||||||
gpu::PipelinePointer _directionalAmbientSphereLight;
|
gpu::PipelinePointer _directionalAmbientSphereLight;
|
||||||
LightLocationsPtr _directionalAmbientSphereLightLocations;
|
|
||||||
|
|
||||||
gpu::PipelinePointer _directionalLight;
|
gpu::PipelinePointer _directionalLight;
|
||||||
LightLocationsPtr _directionalLightLocations;
|
|
||||||
|
gpu::PipelinePointer _directionalSkyboxLightShadow;
|
||||||
|
gpu::PipelinePointer _directionalAmbientSphereLightShadow;
|
||||||
|
gpu::PipelinePointer _directionalLightShadow;
|
||||||
|
|
||||||
gpu::PipelinePointer _pointLight;
|
gpu::PipelinePointer _pointLight;
|
||||||
LightLocationsPtr _pointLightLocations;
|
|
||||||
gpu::PipelinePointer _spotLight;
|
gpu::PipelinePointer _spotLight;
|
||||||
|
|
||||||
|
LightLocationsPtr _directionalSkyboxLightLocations;
|
||||||
|
LightLocationsPtr _directionalAmbientSphereLightLocations;
|
||||||
|
LightLocationsPtr _directionalLightLocations;
|
||||||
|
|
||||||
|
LightLocationsPtr _directionalSkyboxLightShadowLocations;
|
||||||
|
LightLocationsPtr _directionalAmbientSphereLightShadowLocations;
|
||||||
|
LightLocationsPtr _directionalLightShadowLocations;
|
||||||
|
|
||||||
|
LightLocationsPtr _pointLightLocations;
|
||||||
LightLocationsPtr _spotLightLocations;
|
LightLocationsPtr _spotLightLocations;
|
||||||
|
|
||||||
using Lights = std::vector<model::LightPointer>;
|
using Lights = std::vector<model::LightPointer>;
|
||||||
|
|
|
@ -175,6 +175,9 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
|
||||||
setToneMappingExposure(renderContext->getTone().exposure);
|
setToneMappingExposure(renderContext->getTone().exposure);
|
||||||
setToneMappingToneCurve(renderContext->getTone().toneCurve);
|
setToneMappingToneCurve(renderContext->getTone().toneCurve);
|
||||||
|
|
||||||
|
// TODO: For now, lighting is controlled through a singleton, so it is distinct
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->setShadowMapStatus(renderContext->getShadowMapStatus());
|
||||||
|
|
||||||
for (auto job : _jobs) {
|
for (auto job : _jobs) {
|
||||||
job.run(sceneContext, renderContext);
|
job.run(sceneContext, renderContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,15 +131,12 @@ public:
|
||||||
void setDrawHitEffect(bool draw) { enableJob(_drawHitEffectJobIndex, draw); }
|
void setDrawHitEffect(bool draw) { enableJob(_drawHitEffectJobIndex, draw); }
|
||||||
bool doDrawHitEffect() const { return getEnableJob(_drawHitEffectJobIndex); }
|
bool doDrawHitEffect() const { return getEnableJob(_drawHitEffectJobIndex); }
|
||||||
|
|
||||||
|
|
||||||
void setOcclusionStatus(bool draw) { enableJob(_occlusionJobIndex, draw); }
|
void setOcclusionStatus(bool draw) { enableJob(_occlusionJobIndex, draw); }
|
||||||
bool doOcclusionStatus() const { return getEnableJob(_occlusionJobIndex); }
|
bool doOcclusionStatus() const { return getEnableJob(_occlusionJobIndex); }
|
||||||
|
|
||||||
|
|
||||||
void setAntialiasingStatus(bool draw) { enableJob(_antialiasingJobIndex, draw); }
|
void setAntialiasingStatus(bool draw) { enableJob(_antialiasingJobIndex, draw); }
|
||||||
bool doAntialiasingStatus() const { return getEnableJob(_antialiasingJobIndex); }
|
bool doAntialiasingStatus() const { return getEnableJob(_antialiasingJobIndex); }
|
||||||
|
|
||||||
|
|
||||||
void setToneMappingExposure(float exposure);
|
void setToneMappingExposure(float exposure);
|
||||||
float getToneMappingExposure() const;
|
float getToneMappingExposure() const;
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,11 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const Render
|
||||||
assert(sceneContext);
|
assert(sceneContext);
|
||||||
RenderArgs* args = renderContext->getArgs();
|
RenderArgs* args = renderContext->getArgs();
|
||||||
|
|
||||||
|
// This feature is in a debugging stage - it must be turned on explicitly
|
||||||
|
if (!renderContext->getShadowMapStatus()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (!sceneContext->_scene || !args) {
|
if (!sceneContext->_scene || !args) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,9 +21,10 @@ RenderContext::RenderContext(ItemsConfig items, Tone tone, int drawStatus, bool
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderContext::setOptions(bool occlusion, bool fxaa, bool showOwned) {
|
void RenderContext::setOptions(bool occlusion, bool fxaa, bool showOwned, bool shadowMap) {
|
||||||
_occlusionStatus = occlusion;
|
_occlusionStatus = occlusion;
|
||||||
_fxaaStatus = fxaa;
|
_fxaaStatus = fxaa;
|
||||||
|
_shadowMapStatus = shadowMap;
|
||||||
|
|
||||||
if (showOwned) {
|
if (showOwned) {
|
||||||
_drawStatus |= render::showNetworkStatusFlag;
|
_drawStatus |= render::showNetworkStatusFlag;
|
||||||
|
|
|
@ -83,7 +83,8 @@ public:
|
||||||
bool getDrawHitEffect() { return _drawHitEffect; }
|
bool getDrawHitEffect() { return _drawHitEffect; }
|
||||||
bool getOcclusionStatus() { return _occlusionStatus; }
|
bool getOcclusionStatus() { return _occlusionStatus; }
|
||||||
bool getFxaaStatus() { return _fxaaStatus; }
|
bool getFxaaStatus() { return _fxaaStatus; }
|
||||||
void setOptions(bool occlusion, bool fxaa, bool showOwned);
|
bool getShadowMapStatus() { return _shadowMapStatus; }
|
||||||
|
void setOptions(bool occlusion, bool fxaa, bool showOwned, bool shadowMap);
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
int _deferredDebugMode;
|
int _deferredDebugMode;
|
||||||
|
@ -97,6 +98,7 @@ protected:
|
||||||
bool _drawHitEffect;
|
bool _drawHitEffect;
|
||||||
bool _occlusionStatus { false };
|
bool _occlusionStatus { false };
|
||||||
bool _fxaaStatus = { false };
|
bool _fxaaStatus = { false };
|
||||||
|
bool _shadowMapStatus = { false };
|
||||||
|
|
||||||
ItemsConfig _items;
|
ItemsConfig _items;
|
||||||
Tone _tone;
|
Tone _tone;
|
||||||
|
|
Loading…
Reference in a new issue