From bed7752a1a0560b1535525adfa671392b2617f7f Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 15 May 2018 12:27:04 +0200 Subject: [PATCH 1/2] Fixed bug with highlighting and TAA --- libraries/render-utils/src/HighlightEffect.cpp | 9 +++++++-- libraries/render-utils/src/HighlightEffect.h | 6 +++--- libraries/render-utils/src/RenderDeferredTask.cpp | 9 ++++++--- libraries/render-utils/src/RenderDeferredTask.h | 2 +- libraries/render/src/render/DrawStatus.cpp | 6 +++++- libraries/render/src/render/DrawStatus.h | 5 +++-- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index d151da766b..3905d3a54c 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -169,6 +169,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c glm::mat4 projMat; Transform viewMat; + const auto jitter = inputs.get2(); args->getViewFrustum().evalProjectionMatrix(projMat); args->getViewFrustum().evalViewTransform(viewMat); @@ -183,6 +184,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c // Setup camera, projection and viewport for all items batch.setViewportTransform(args->_viewport); batch.setProjectionTransform(projMat); + batch.setProjectionJitter(jitter.x, jitter.y); batch.setViewTransform(viewMat); std::vector skinnedShapeKeys{}; @@ -356,6 +358,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); RenderArgs* args = renderContext->args; + const auto jitter = input.get2(); gpu::doInBatch("DebugHighlight::run", args->_context, [&](gpu::Batch& batch) { batch.setViewportTransform(args->_viewport); @@ -368,6 +371,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons args->getViewFrustum().evalProjectionMatrix(projMat); args->getViewFrustum().evalViewTransform(viewMat); batch.setProjectionTransform(projMat); + batch.setProjectionJitter(jitter.x, jitter.y); batch.setViewTransform(viewMat, true); batch.setModelTransform(Transform()); @@ -480,6 +484,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren const auto sceneFrameBuffer = inputs.getN(1); const auto primaryFramebuffer = inputs.getN(2); const auto deferredFrameTransform = inputs.getN(3); + const auto jitter = inputs.getN(4); // Prepare the ShapePipeline auto shapePlumber = std::make_shared(); @@ -515,7 +520,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren stream << "HighlightMask" << i; name = stream.str(); } - const auto drawMaskInputs = DrawHighlightMask::Inputs(sortedBounds, highlightRessources).asVarying(); + const auto drawMaskInputs = DrawHighlightMask::Inputs(sortedBounds, highlightRessources, jitter).asVarying(); const auto highlightedRect = task.addJob(name, drawMaskInputs, i, shapePlumber, sharedParameters); if (i == 0) { highlight0Rect = highlightedRect; @@ -532,7 +537,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren } // Debug highlight - const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast(highlight0Rect)).asVarying(); + const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast(highlight0Rect), jitter).asVarying(); task.addJob("HighlightDebug", debugInputs); } diff --git a/libraries/render-utils/src/HighlightEffect.h b/libraries/render-utils/src/HighlightEffect.h index 90a8e730ce..7c1db795fb 100644 --- a/libraries/render-utils/src/HighlightEffect.h +++ b/libraries/render-utils/src/HighlightEffect.h @@ -113,7 +113,7 @@ private: class DrawHighlightMask { public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using Outputs = glm::ivec4; using JobModel = render::Job::ModelIO; @@ -182,7 +182,7 @@ signals: class DebugHighlight { public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using Config = DebugHighlightConfig; using JobModel = render::Job::ModelI; @@ -205,7 +205,7 @@ private: class DrawHighlightTask { public: - using Inputs = render::VaryingSet4; + using Inputs = render::VaryingSet5; using Config = render::Task::Config; using JobModel = render::Task::ModelI; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index bea298122e..ab1d831ead 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -178,7 +178,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("DrawHazeDeferred", drawHazeInputs); // Render transparent objects forward in LightingBuffer - const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel, lightClusters).asVarying(); + const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel, lightClusters, jitter).asVarying(); task.addJob("DrawTransparentDeferred", transparentsInputs, shapePlumber); // Light Cluster Grid Debuging job @@ -192,7 +192,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto selectionBaseName = "contextOverlayHighlightList"; const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents); - const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, lightingFramebuffer, deferredFrameTransform).asVarying(); + const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, lightingFramebuffer, deferredFrameTransform, jitter).asVarying(); task.addJob("DrawHighlight", outlineInputs); task.addJob("HighlightRangeTimer", outlineRangeTimer); @@ -277,7 +277,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Grab a texture map representing the different status icons and assign that to the drawStatsuJob auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg"; auto statusIconMap = DependencyManager::get()->getImageTexture(iconMapPath, image::TextureUsage::STRICT_TEXTURE); - task.addJob("DrawStatus", opaques, DrawStatus(statusIconMap)); + const auto drawStatusInputs = DrawStatus::Input(opaques, jitter).asVarying(); + task.addJob("DrawStatus", drawStatusInputs, DrawStatus(statusIconMap)); } task.addJob("DrawZoneStack", deferredFrameTransform); @@ -315,6 +316,7 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs& const auto& inItems = inputs.get0(); const auto& lightingModel = inputs.get1(); const auto& lightClusters = inputs.get2(); + const auto jitter = inputs.get3(); auto deferredLightingEffect = DependencyManager::get(); RenderArgs* args = renderContext->args; @@ -332,6 +334,7 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs& args->getViewFrustum().evalViewTransform(viewMat); batch.setProjectionTransform(projMat); + batch.setProjectionJitter(jitter.x, jitter.y); batch.setViewTransform(viewMat); // Setup lighting model for all items; diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index b923ec0878..9917058790 100644 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -41,7 +41,7 @@ protected: class DrawDeferred { public: - using Inputs = render::VaryingSet3 ; + using Inputs = render::VaryingSet4; using Config = DrawDeferredConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 56802a3239..496b2000a9 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -104,7 +104,7 @@ void DrawStatus::configure(const Config& config) { _showNetwork = config.showNetwork; } -void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds& inItems) { +void DrawStatus::run(const RenderContextPointer& renderContext, const Input& input) { assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); RenderArgs* args = renderContext->args; @@ -112,6 +112,9 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds const int NUM_STATUS_VEC4_PER_ITEM = 2; const int VEC4_LENGTH = 4; + const auto& inItems = input.get0(); + const auto jitter = input.get1(); + // FIrst thing, we collect the bound and the status for all the items we want to render int nbItems = 0; { @@ -171,6 +174,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const ItemBounds batch.setViewportTransform(args->_viewport); batch.setProjectionTransform(projMat); + batch.setProjectionJitter(jitter.x, jitter.y); batch.setViewTransform(viewMat, true); batch.setModelTransform(Transform()); diff --git a/libraries/render/src/render/DrawStatus.h b/libraries/render/src/render/DrawStatus.h index 2e0adb4653..9e05471cd6 100644 --- a/libraries/render/src/render/DrawStatus.h +++ b/libraries/render/src/render/DrawStatus.h @@ -39,13 +39,14 @@ namespace render { class DrawStatus { public: using Config = DrawStatusConfig; - using JobModel = Job::ModelI; + using Input = VaryingSet2; + using JobModel = Job::ModelI; DrawStatus() {} DrawStatus(const gpu::TexturePointer statusIconMap) { setStatusIconMap(statusIconMap); } void configure(const Config& config); - void run(const RenderContextPointer& renderContext, const ItemBounds& inItems); + void run(const RenderContextPointer& renderContext, const Input& input); const gpu::PipelinePointer getDrawItemBoundsPipeline(); const gpu::PipelinePointer getDrawItemStatusPipeline(); From d10b5a16f291b860a0c213f1ad0636cf0b94f55b Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 15 May 2018 15:09:02 +0200 Subject: [PATCH 2/2] Turned off jitter with FXAA --- .../render-utils/src/AntialiasingEffect.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index f77b4fc68b..249d2bbc47 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -482,16 +482,14 @@ JitterSample::SampleSequence::SampleSequence(){ } void JitterSample::configure(const Config& config) { - _freeze = config.freeze; - if (config.stop || _freeze) { + _freeze = config.stop || config.freeze; + if (config.freeze) { auto pausedIndex = config.getIndex(); if (_sampleSequence.currentIndex != pausedIndex) { _sampleSequence.currentIndex = pausedIndex; } - } else { - if (_sampleSequence.currentIndex < 0) { - _sampleSequence.currentIndex = config.getIndex(); - } + } else if (config.stop) { + _sampleSequence.currentIndex = -1; } _scale = config.scale; } @@ -505,7 +503,12 @@ void JitterSample::run(const render::RenderContextPointer& renderContext, Output current = -1; } } - jitter = _sampleSequence.offsets[(current < 0 ? SEQUENCE_LENGTH : current)]; + + jitter.x = 0.0f; + jitter.y = 0.0f; + if (current >= 0) { + jitter = _sampleSequence.offsets[current]; + } }