diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 970672787e..d5579aa022 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -373,12 +373,6 @@ void RenderableZoneEntityItem::updateKeyZoneItemFromEntity(RenderableZoneEntityI if (!success) { keyZonePayload.editBound() = render::Item::Bound(); } - - updateKeySunFromEntity(keyZonePayload); - - updateKeyAmbientFromEntity(keyZonePayload); - - updateKeyBackgroundFromEntity(keyZonePayload); } @@ -387,8 +381,25 @@ void RenderableZoneEntityItem::sceneUpdateRenderItemFromEntity(render::Transacti return; } - transaction.updateItem(_myMetaItem, [&](RenderableZoneEntityItemMeta& data) { + bool sunChanged = _keyLightPropertiesChanged; + bool backgroundChanged = _backgroundPropertiesChanged; + bool stageChanged = _stagePropertiesChanged; + bool skyboxChanged = _skyboxPropertiesChanged; + + transaction.updateItem(_myMetaItem, [=](RenderableZoneEntityItemMeta& data) { + updateKeyZoneItemFromEntity(data); + + if (sunChanged) { + updateKeySunFromEntity(data); + } + + if (sunChanged || skyboxChanged) { + updateKeyAmbientFromEntity(data); + } + if (backgroundChanged || skyboxChanged) { + updateKeyBackgroundFromEntity(data); + } }); } diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 21df88d4c4..b844da8bbe 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -123,7 +123,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Draw Lights just add the lights to the current list of lights to deal with. NOt really gpu job for now. task.addJob("DrawLight", lights); - // Filter zones + // Filter zones from the general metas bucket const auto zones = task.addJob("ZoneRenderer", metas); // Light Clustering @@ -138,12 +138,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("RenderDeferred", deferredLightingInputs); - // Use Stencil and draw background in Lighting buffer to complete filling in the opaque - //const auto backgroundInputs = DrawBackgroundDeferred::Inputs(background, lightingModel).hasVarying(); - //task.addJob("DrawBackgroundDeferred", backgroundInputs); - + // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job task.addJob("DrawBackgroundDeferred", lightingModel); - + // Render transparent objects forward in LightingBuffer const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).hasVarying(); task.addJob("DrawTransparentDeferred", transparentsInputs, shapePlumber); @@ -207,7 +204,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("DrawStatus", opaques, DrawStatus(statusIconMap)); } - task.addJob("DebugZoneLighting", deferredFrameTransform); + task.addJob("DrawZoneStack", deferredFrameTransform); } diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index c51e8205cd..3b4870fd3f 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -127,34 +127,34 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I auto deferredTransform = inputs; auto lightStage = DependencyManager::get()->getLightStage(); - std::vector keyLightStack; + std::vector keyLightStack; if (lightStage && lightStage->_currentFrame._sunLights.size()) { - for (auto index : lightStage->_currentFrame._sunLights) { - keyLightStack.push_back(lightStage->getLight(index)); - } + for (auto index : lightStage->_currentFrame._sunLights) { + keyLightStack.push_back(lightStage->getLight(index)); + } } - keyLightStack.push_back(DependencyManager::get()->getGlobalLight()); + keyLightStack.push_back(DependencyManager::get()->getGlobalLight()); - std::vector ambientLightStack; - if (lightStage && lightStage->_currentFrame._ambientLights.size()) { - for (auto index : lightStage->_currentFrame._ambientLights) { - ambientLightStack.push_back(lightStage->getLight(index)); - } - } - ambientLightStack.push_back(DependencyManager::get()->getGlobalLight()); + std::vector ambientLightStack; + if (lightStage && lightStage->_currentFrame._ambientLights.size()) { + for (auto index : lightStage->_currentFrame._ambientLights) { + ambientLightStack.push_back(lightStage->getLight(index)); + } + } + ambientLightStack.push_back(DependencyManager::get()->getGlobalLight()); auto backgroundStage = DependencyManager::get()->getBackgroundStage(); - std::vector skyboxStack; + std::vector skyboxStack; if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) { - for (auto index : backgroundStage->_currentFrame._backgrounds) { - auto background = backgroundStage->getBackground(index); - if (background) { - skyboxStack.push_back(background->getSkybox()); - } - } + for (auto index : backgroundStage->_currentFrame._backgrounds) { + auto background = backgroundStage->getBackground(index); + if (background) { + skyboxStack.push_back(background->getSkybox()); + } + } } - skyboxStack.push_back(DependencyManager::get()->getDefaultSkybox()); + skyboxStack.push_back(DependencyManager::get()->getDefaultSkybox()); gpu::doInBatch(args->_context, [=](gpu::Batch& batch) { @@ -169,40 +169,40 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I batch.setUniformBuffer(ZONE_DEFERRED_TRANSFORM_BUFFER, deferredTransform->getFrameTransformBuffer()); batch.setPipeline(getKeyLightPipeline()); - auto numKeys = keyLightStack.size(); - for (int i = numKeys - 1; i >= 0; i--) { - model.setTranslation(glm::vec3(-4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); - batch.setModelTransform(model); - if (keyLightStack[i]) { - batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLightStack[i]->getLightSchemaBuffer()); - batch.draw(gpu::TRIANGLE_STRIP, 4); - } - } + auto numKeys = keyLightStack.size(); + for (int i = numKeys - 1; i >= 0; i--) { + model.setTranslation(glm::vec3(-4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); + batch.setModelTransform(model); + if (keyLightStack[i]) { + batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLightStack[i]->getLightSchemaBuffer()); + batch.draw(gpu::TRIANGLE_STRIP, 4); + } + } batch.setPipeline(getAmbientPipeline()); - auto numAmbients = ambientLightStack.size(); - for (int i = numAmbients - 1; i >= 0; i--) { - model.setTranslation(glm::vec3(0.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); - batch.setModelTransform(model); - if (ambientLightStack[i]) { - batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, ambientLightStack[i]->getAmbientSchemaBuffer()); - if (ambientLightStack[i]->getAmbientMap()) { - batch.setResourceTexture(ZONE_AMBIENT_MAP, ambientLightStack[i]->getAmbientMap()); - } - batch.draw(gpu::TRIANGLE_STRIP, 4); - } - } + auto numAmbients = ambientLightStack.size(); + for (int i = numAmbients - 1; i >= 0; i--) { + model.setTranslation(glm::vec3(0.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); + batch.setModelTransform(model); + if (ambientLightStack[i]) { + batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, ambientLightStack[i]->getAmbientSchemaBuffer()); + if (ambientLightStack[i]->getAmbientMap()) { + batch.setResourceTexture(ZONE_AMBIENT_MAP, ambientLightStack[i]->getAmbientMap()); + } + batch.draw(gpu::TRIANGLE_STRIP, 4); + } + } batch.setPipeline(getBackgroundPipeline()); - auto numBackgrounds = skyboxStack.size(); - for (int i = numBackgrounds - 1; i >= 0; i--) { - model.setTranslation(glm::vec3(4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); - batch.setModelTransform(model); - if (skyboxStack[i]) { - batch.setResourceTexture(ZONE_SKYBOX_MAP, skyboxStack[i]->getCubemap()); - batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skyboxStack[i]->getSchemaBuffer()); - batch.draw(gpu::TRIANGLE_STRIP, 4); - } - } + auto numBackgrounds = skyboxStack.size(); + for (int i = numBackgrounds - 1; i >= 0; i--) { + model.setTranslation(glm::vec3(4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0))); + batch.setModelTransform(model); + if (skyboxStack[i]) { + batch.setResourceTexture(ZONE_SKYBOX_MAP, skyboxStack[i]->getCubemap()); + batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skyboxStack[i]->getSchemaBuffer()); + batch.draw(gpu::TRIANGLE_STRIP, 4); + } + } }); } diff --git a/libraries/render-utils/src/ZoneRenderer.h b/libraries/render-utils/src/ZoneRenderer.h index 40f9db2995..5737499270 100644 --- a/libraries/render-utils/src/ZoneRenderer.h +++ b/libraries/render-utils/src/ZoneRenderer.h @@ -54,11 +54,17 @@ protected: class DebugZoneLighting { public: + class Config : public render::JobConfig { + public: + Config(bool enabled = false) : JobConfig(enabled) {} + }; + using Inputs = DeferredFrameTransformPointer; - using JobModel = render::Job::ModelI; + using JobModel = render::Job::ModelI; DebugZoneLighting() {} + void configure(const Config& configuration) {} void run(const render::RenderContextPointer& context, const Inputs& inputs); protected: