From 1817b8ef2f6cc8cdf3ac16cb6823b385a4ef951c Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 24 Feb 2016 16:07:28 -0800 Subject: [PATCH] Use only skyboxTexture in DeferredLightingEffect --- interface/src/Application.cpp | 4 ++-- .../render-utils/src/DeferredLightingEffect.cpp | 17 ++++++++--------- .../render-utils/src/DeferredLightingEffect.h | 5 ++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6205d3291b..132ffd0fb6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3818,8 +3818,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // Setup the current Zone Entity lighting { - auto sun = DependencyManager::get()->getSkyStage()->getSunLight(); - DependencyManager::get()->setGlobalLight(sun); + auto stage = DependencyManager::get()->getSkyStage(); + DependencyManager::get()->setGlobalLight(stage->getSunLight(), stage->getSkybox()->getCubemap()); } { diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 605dfaa2b9..8fc103e23e 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -312,15 +312,13 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo // First Global directional light and ambient pass { - bool useSkyboxCubemap = (_skybox) && (_skybox->getCubemap()); - auto& program = _shadowMapEnabled ? _directionalLightShadow : _directionalLight; LightLocationsPtr locations = _shadowMapEnabled ? _directionalLightShadowLocations : _directionalLightLocations; // Setup the global directional pass pipeline { if (_shadowMapEnabled) { - if (useSkyboxCubemap) { + if (_skyboxTexture) { program = _directionalSkyboxLightShadow; locations = _directionalSkyboxLightShadowLocations; } else if (_ambientLightMode > -1) { @@ -328,7 +326,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo locations = _directionalAmbientSphereLightShadowLocations; } } else { - if (useSkyboxCubemap) { + if (_skyboxTexture) { program = _directionalSkyboxLight; locations = _directionalSkyboxLightLocations; } else if (_ambientLightMode > -1) { @@ -356,7 +354,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo geometryCache->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color); } - if (useSkyboxCubemap) { + if (_skyboxTexture) { batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr); } } @@ -501,9 +499,8 @@ void DeferredLightingEffect::setupKeyLightBatch(gpu::Batch& batch, int lightBuff batch.setUniformBuffer(lightBufferUnit, globalLight->getSchemaBuffer()); } - bool useSkyboxCubemap = (_skybox) && (_skybox->getCubemap()); - if (useSkyboxCubemap && (skyboxCubemapUnit >= 0)) { - batch.setResourceTexture(skyboxCubemapUnit, _skybox->getCubemap()); + if (_skyboxTexture && (skyboxCubemapUnit >= 0)) { + batch.setResourceTexture(skyboxCubemapUnit, _skyboxTexture); } } @@ -562,13 +559,15 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo } -void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light) { +void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) { auto globalLight = _allocatedLights.front(); globalLight->setDirection(light->getDirection()); globalLight->setColor(light->getColor()); globalLight->setIntensity(light->getIntensity()); globalLight->setAmbientIntensity(light->getAmbientIntensity()); globalLight->setAmbientSphere(light->getAmbientSphere()); + + _skyboxTexture = skyboxTexture; } model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index b7a32c2c16..2c33944606 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -18,7 +18,6 @@ #include #include "model/Light.h" -#include "model/Stage.h" #include "model/Geometry.h" #include "render/Context.h" @@ -49,7 +48,7 @@ public: void setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit); // update global lighting - void setGlobalLight(const model::LightPointer& light); + void setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture); const LightStage& getLightStage() { return _lightStage; } void setShadowMapEnabled(bool enable) { _shadowMapEnabled = enable; }; @@ -96,7 +95,7 @@ private: std::vector _spotLights; int _ambientLightMode = 0; - model::SkyboxPointer _skybox; + gpu::TexturePointer _skyboxTexture; // Class describing the uniform buffer with all the parameters common to the deferred shaders class DeferredTransform {