Fixed bug with highlighting and TAA

This commit is contained in:
Olivier Prat 2018-05-15 12:27:04 +02:00
parent 5866442bf6
commit bed7752a1a
6 changed files with 25 additions and 12 deletions

View file

@ -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<ShapeKey> 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<Inputs>(1);
const auto primaryFramebuffer = inputs.getN<Inputs>(2);
const auto deferredFrameTransform = inputs.getN<Inputs>(3);
const auto jitter = inputs.getN<Inputs>(4);
// Prepare the ShapePipeline
auto shapePlumber = std::make_shared<ShapePlumber>();
@ -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<DrawHighlightMask>(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<const render::Varying&>(highlight0Rect)).asVarying();
const auto debugInputs = DebugHighlight::Inputs(highlightRessources, const_cast<const render::Varying&>(highlight0Rect), jitter).asVarying();
task.addJob<DebugHighlight>("HighlightDebug", debugInputs);
}

View file

@ -113,7 +113,7 @@ private:
class DrawHighlightMask {
public:
using Inputs = render::VaryingSet2<render::ShapeBounds, HighlightRessourcesPointer>;
using Inputs = render::VaryingSet3<render::ShapeBounds, HighlightRessourcesPointer, glm::vec2>;
using Outputs = glm::ivec4;
using JobModel = render::Job::ModelIO<DrawHighlightMask, Inputs, Outputs>;
@ -182,7 +182,7 @@ signals:
class DebugHighlight {
public:
using Inputs = render::VaryingSet2<HighlightRessourcesPointer, glm::ivec4>;
using Inputs = render::VaryingSet3<HighlightRessourcesPointer, glm::ivec4, glm::vec2>;
using Config = DebugHighlightConfig;
using JobModel = render::Job::ModelI<DebugHighlight, Inputs, Config>;
@ -205,7 +205,7 @@ private:
class DrawHighlightTask {
public:
using Inputs = render::VaryingSet4<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer>;
using Inputs = render::VaryingSet5<RenderFetchCullSortTask::BucketList, DeferredFramebufferPointer, gpu::FramebufferPointer, DeferredFrameTransformPointer, glm::vec2>;
using Config = render::Task::Config;
using JobModel = render::Task::ModelI<DrawHighlightTask, Inputs, Config>;

View file

@ -178,7 +178,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawHaze>("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<DrawDeferred>("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<DrawHighlightTask>("DrawHighlight", outlineInputs);
task.addJob<EndGPURangeTimer>("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<TextureCache>()->getImageTexture(iconMapPath, image::TextureUsage::STRICT_TEXTURE);
task.addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
const auto drawStatusInputs = DrawStatus::Input(opaques, jitter).asVarying();
task.addJob<DrawStatus>("DrawStatus", drawStatusInputs, DrawStatus(statusIconMap));
}
task.addJob<DebugZoneLighting>("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<DeferredLightingEffect>();
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;

View file

@ -41,7 +41,7 @@ protected:
class DrawDeferred {
public:
using Inputs = render::VaryingSet3 <render::ItemBounds, LightingModelPointer, LightClustersPointer>;
using Inputs = render::VaryingSet4<render::ItemBounds, LightingModelPointer, LightClustersPointer, glm::vec2>;
using Config = DrawDeferredConfig;
using JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>;

View file

@ -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());

View file

@ -39,13 +39,14 @@ namespace render {
class DrawStatus {
public:
using Config = DrawStatusConfig;
using JobModel = Job::ModelI<DrawStatus, ItemBounds, Config>;
using Input = VaryingSet2<ItemBounds, glm::vec2>;
using JobModel = Job::ModelI<DrawStatus, Input, Config>;
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();