diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index b6a91888a1..2187cb70b1 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -511,12 +511,19 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, auto keyLight = lightAndShadow.first; + model::LightPointer keyAmbientLight; + if (lightStage && lightStage->_currentFrame._ambientLights.size()) { + keyAmbientLight = lightStage->getLight(lightStage->_currentFrame._ambientLights.front()); + } + bool hasAmbientMap = (keyAmbientLight != nullptr); + // Setup the global directional pass pipeline { if (deferredLightingEffect->_shadowMapEnabled) { + // If the keylight has an ambient Map then use the Skybox version of the pass // otherwise use the ambient sphere version - if (keyLight->getAmbientMap()) { + if (hasAmbientMap) { program = deferredLightingEffect->_directionalSkyboxLightShadow; locations = deferredLightingEffect->_directionalSkyboxLightShadowLocations; } else { @@ -526,7 +533,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, } else { // If the keylight has an ambient Map then use the Skybox version of the pass // otherwise use the ambient sphere version - if (keyLight->getAmbientMap()) { + if (hasAmbientMap) { program = deferredLightingEffect->_directionalSkyboxLight; locations = deferredLightingEffect->_directionalSkyboxLightLocations; } else {