From b09d0b10e90f1ceaa33a399bbbdd6f4bc436b492 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Sun, 9 Dec 2018 22:54:49 -0800 Subject: [PATCH] cleaning light clusters --- libraries/render-utils/src/LightClusters.cpp | 9 +-- libraries/render-utils/src/LightClusters.h | 10 +-- .../render-utils/src/RenderDeferredTask.cpp | 76 ++++++++++--------- .../render-utils/src/RenderDeferredTask.h | 5 -- 4 files changed, 48 insertions(+), 52 deletions(-) diff --git a/libraries/render-utils/src/LightClusters.cpp b/libraries/render-utils/src/LightClusters.cpp index 252416ea9d..3dc826d56c 100644 --- a/libraries/render-utils/src/LightClusters.cpp +++ b/libraries/render-utils/src/LightClusters.cpp @@ -543,7 +543,7 @@ void LightClusteringPass::configure(const Config& config) { _freeze = config.freeze; } -void LightClusteringPass::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& output) { +void LightClusteringPass::run(const render::RenderContextPointer& renderContext, const Input& inputs, Output& output) { auto args = renderContext->args; auto deferredTransform = inputs.get0(); @@ -638,10 +638,9 @@ void DebugLightClusters::run(const render::RenderContextPointer& renderContext, } auto deferredTransform = inputs.get0(); - auto deferredFramebuffer = inputs.get1(); - auto lightingModel = inputs.get2(); - auto linearDepthTarget = inputs.get3(); - auto lightClusters = inputs.get4(); + auto lightingModel = inputs.get1(); + auto linearDepthTarget = inputs.get2(); + auto lightClusters = inputs.get3(); auto args = renderContext->args; diff --git a/libraries/render-utils/src/LightClusters.h b/libraries/render-utils/src/LightClusters.h index e109e43aaa..60978e76e8 100644 --- a/libraries/render-utils/src/LightClusters.h +++ b/libraries/render-utils/src/LightClusters.h @@ -167,16 +167,16 @@ protected: class LightClusteringPass { public: - using Inputs = render::VaryingSet4; - using Outputs = LightClustersPointer; + using Input = render::VaryingSet4; + using Output = LightClustersPointer; using Config = LightClusteringPassConfig; - using JobModel = render::Job::ModelIO; + using JobModel = render::Job::ModelIO; LightClusteringPass(); void configure(const Config& config); - void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& output); + void run(const render::RenderContextPointer& renderContext, const Input& input, Output& output); protected: LightClustersPointer _lightClusters; @@ -213,7 +213,7 @@ protected: class DebugLightClusters { public: - using Inputs = render::VaryingSet5 < DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, LinearDepthFramebufferPointer, LightClustersPointer>; + using Inputs = render::VaryingSet4 < DeferredFrameTransformPointer, LightingModelPointer, LinearDepthFramebufferPointer, LightClustersPointer>; using Config = DebugLightClustersConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 223efbeba4..a6242cd84e 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -84,7 +84,7 @@ public: class RenderDeferredTaskDebug { public: using Input = render::VaryingSet9; // using Config = RenderDeferredTaskConfig; using JobModel = render::Task::ModelI; @@ -112,18 +112,6 @@ void RenderDeferredTask::configure(const Config& config) { upsamplePrimaryBufferConfig->setProperty("factor", 1.0f / config.resolutionScale); } -const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName, - const render::Varying& metas, - const render::Varying& opaques, - const render::Varying& transparents) { - const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying(); - const auto selectedMetas = task.addJob("MetaSelection", selectMetaInput, selectionName); - const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas, std::string()).asVarying(); - const auto selectedMetasAndOpaques = task.addJob("OpaqueSelection", selectMetaAndOpaqueInput, selectionName); - const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, std::string()).asVarying(); - return task.addJob("TransparentSelection", selectItemInput, selectionName); -} - void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, bool renderShadows) { const auto& inputs = input.get(); const auto& fetchedItems = inputs.get0(); @@ -220,7 +208,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Light Clustering // Create the cluster grid of lights, cpu job for now - const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, lightFrame, linearDepthTarget).asVarying(); + const auto lightClusteringPassInputs = LightClusteringPass::Input(deferredFrameTransform, lightingModel, lightFrame, linearDepthTarget).asVarying(); const auto lightClusters = task.addJob("LightClustering", lightClusteringPassInputs); // DeferredBuffer is complete, now let's shade it into the LightingBuffer @@ -239,16 +227,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto transparentsInputs = DrawDeferred::Inputs(transparents, hazeFrame, lightFrame, lightingModel, lightClusters, jitter).asVarying(); task.addJob("DrawTransparentDeferred", transparentsInputs, shapePlumber); - // Light Cluster Grid Debuging job - { - const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying(); - task.addJob("DebugLightClusters", debugLightClustersInputs); - } - const auto outlineRangeTimer = task.addJob("BeginHighlightRangeTimer", "Highlight"); - // Select items that need to be outlined - const auto selectionBaseName = "contextOverlayHighlightList"; - const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents); const auto outlineInputs = DrawHighlightTask::Inputs(items, deferredFramebuffer, lightingFramebuffer, deferredFrameTransform, jitter).asVarying(); task.addJob("DrawHighlight", outlineInputs); @@ -277,7 +256,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 debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, inputs[2], zones, selectedItems, currentStageFrames, prepareDeferredOutputs, deferredFrameTransform, jitter, lightingModel).asVarying(); + const auto debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, inputs[2], lightingStageInputs, lightClusters, linearDepthTarget, prepareDeferredOutputs, deferredFrameTransform, jitter, lightingModel).asVarying(); task.addJob("DebugRenderDeferredTask", debugInputs); } @@ -308,9 +287,6 @@ void RenderDeferredTaskDebug::configure(const Config& config) { }*/ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input, render::Varying& outputs) { -// RenderFetchCullSortTask::Output, RenderShadowTask::Output, -// ZoneRendererTask::Outputs, SelectItems::Outputs, FetchCurrentFrames::Outputs, -// PrepareDeferred::Outputs, GenerateDeferredFrameTransform::Output, JitterSample::Output const auto& inputs = input.get(); @@ -334,18 +310,23 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input // RenderShadowTask out const auto& renderShadowTaskOut = inputs[1]; - // Zones - const auto& zones = inputs[2]; + // Extract the Lighting Stages Current frame ( and zones) + const auto lightingStageInputs = inputs.get2(); + // Fetch the current frame stacks from all the stages + const auto stageCurrentFrames = lightingStageInputs.get0(); + const auto lightFrame = stageCurrentFrames[0]; + const auto backgroundFrame = stageCurrentFrames[1]; + const auto hazeFrame = stageCurrentFrames[2]; + const auto bloomFrame = stageCurrentFrames[3]; - // Selected objects - const auto& selectedItems = inputs[3]; + // Zones + const auto& zones = lightingStageInputs[1]; - // Stage current frames - const auto& stageCurrentFrames = inputs.get4();//[4]; - const auto lightFrame = stageCurrentFrames[0]; - const auto backgroundFrame = stageCurrentFrames[1]; - const auto hazeFrame = stageCurrentFrames[2]; - const auto bloomFrame = stageCurrentFrames[3]; + // Light CLuster + const auto& lightClusters = inputs[3]; + + // linear Depth Target + const auto& linearDepthTarget = inputs[4]; // PrepareDeferred out const auto& deferredFramebuffer = inputs[5]; @@ -360,6 +341,14 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input const auto& lightingModel = inputs[8]; + + // Light Cluster Grid Debuging job + { + const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget, lightClusters).asVarying(); + task.addJob("DebugLightClusters", debugLightClustersInputs); + } + + { // Debug the bounds of the rendered items, still look at the zbuffer task.addJob("DrawMetaBounds", metas); task.addJob("DrawOpaqueBounds", opaques); @@ -383,6 +372,19 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input task.addJob(jobName, shadowBBox, glm::vec3(1.0f, tint, 0.0f)); } } + } + + { // Debug Selection... + // TODO: It s busted + // Select items that need to be outlined and show them + const auto selectionBaseName = "contextOverlayHighlightList"; + + const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying(); + const auto selectedMetas = task.addJob("MetaSelection", selectMetaInput, selectionBaseName); + const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas, std::string()).asVarying(); + const auto selectedMetasAndOpaques = task.addJob("OpaqueSelection", selectMetaAndOpaqueInput, selectionBaseName); + const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, std::string()).asVarying(); + const auto selectedItems = task.addJob("TransparentSelection", selectItemInput, selectionBaseName); // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true task.addJob("DrawSelectionBounds", selectedItems); diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 81f158918c..400bd66def 100644 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -147,11 +147,6 @@ public: void build(JobModel& task, const render::Varying& input, render::Varying& output, bool renderShadows); private: - static const render::Varying addSelectItemJobs(JobModel& task, - const char* selectionName, - const render::Varying& metas, - const render::Varying& opaques, - const render::Varying& transparents); }; #endif // hifi_RenderDeferredTask_h