Showing the changes to libraries/render-utils/src/RenderDeferredTask.cpp (1 of 746 files). Show all
Unified · Split
| @@ -36,15 +36,17 @@ · 35 unmodified lines | ||
| 36 | 36 | #include "TextureCache.h" |
| 37 | 37 | #include "ZoneRenderer.h" |
| 38 | 38 | #include "FadeEffect.h" |
| 39 | +#include "RenderUtilsLogging.h" | |
| 39 | 40 | |
| 40 | 41 | #include "AmbientOcclusionEffect.h" |
| 41 | 42 | #include "AntialiasingEffect.h" |
| 42 | 43 | #include "ToneMappingEffect.h" |
| 43 | 44 | #include "SubsurfaceScattering.h" |
| 44 | −#include "OutlineEffect.h" | |
| 45 | − | |
| 46 | −#include <gpu/StandardShaderLib.h> | |
| 45 | +#include "DrawHaze.h" | |
| 46 | +#include "BloomEffect.h" | |
| 47 | +#include "HighlightEffect.h" | |
| 47 | 48 | |
| 49 | +#include <sstream> | |
| 48 | 50 | |
| 49 | 51 | using namespace render; |
| 50 | 52 | extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); |
| @@ -58,6 +60,18 @@ void RenderDeferredTask::configure(const Config& config) · 7 unmodified lines | ||
| 58 | 60 | { |
| 59 | 61 | } |
| 60 | 62 | |
| 63 | +const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName, | |
| 64 | + const render::Varying& metas, | |
| 65 | + const render::Varying& opaques, | |
| 66 | + const render::Varying& transparents) { | |
| 67 | + const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying(); | |
| 68 | + const auto selectedMetas = task.addJob<SelectItems>("MetaSelection", selectMetaInput, selectionName); | |
| 69 | + const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas, std::string()).asVarying(); | |
| 70 | + const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput, selectionName); | |
| 71 | + const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, std::string()).asVarying(); | |
| 72 | + return task.addJob<SelectItems>("TransparentSelection", selectItemInput, selectionName); | |
| 73 | +} | |
| 74 | + | |
| 61 | 75 | void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { |
| 62 | 76 | const auto& items = input.get<Input>(); |
| 63 | 77 | auto fadeEffect = DependencyManager::get<FadeEffect>(); |
| @@ -98,15 +112,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 34 unmodified lines | ||
| 98 | 112 | // draw a stencil mask in hidden regions of the framebuffer. |
| 99 | 113 | task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer); |
| 100 | 114 | |
| 101 | − // Select items that need to be outlined | |
| 102 | − const auto selectionName = "contextOverlayHighlightList"; | |
| 103 | − const auto selectMetaInput = SelectItems::Inputs(metas, Varying()).asVarying(); | |
| 104 | − const auto selectedMetas = task.addJob<SelectItems>("PassTestMetaSelection", selectMetaInput, selectionName); | |
| 105 | − const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas).asVarying(); | |
| 106 | − const auto selectedMetasAndOpaques = task.addJob<SelectItems>("PassTestOpaqueSelection", selectMetaAndOpaqueInput, selectionName); | |
| 107 | − const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques).asVarying(); | |
| 108 | − const auto selectedItems = task.addJob<SelectItems>("PassTestTransparentSelection", selectItemInput, selectionName); | |
| 109 | − | |
| 110 | 115 | // Render opaque objects in DeferredBuffer |
| 111 | 116 | const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying(); |
| 112 | 117 | task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber); |
| @@ -153,11 +158,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines | ||
| 153 | 158 | // Create the cluster grid of lights, cpu job for now |
| 154 | 159 | const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget).asVarying(); |
| 155 | 160 | const auto lightClusters = task.addJob<LightClusteringPass>("LightClustering", lightClusteringPassInputs); |
| 156 | − | |
| 157 | − | |
| 161 | + | |
| 162 | + // Add haze model | |
| 163 | + const auto hazeModel = task.addJob<FetchHazeStage>("HazeModel"); | |
| 164 | + | |
| 158 | 165 | // DeferredBuffer is complete, now let's shade it into the LightingBuffer |
| 159 | 166 | const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, |
| 160 | − surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters).asVarying(); | |
| 167 | + surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters, hazeModel).asVarying(); | |
| 161 | 168 | |
| 162 | 169 | task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs); |
| 163 | 170 | |
| @@ -169,30 +176,50 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 5 unmodified lines | ||
| 169 | 176 | const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).asVarying(); |
| 170 | 177 | task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber); |
| 171 | 178 | |
| 172 | − // LIght Cluster Grid Debuging job | |
| 179 | + // Light Cluster Grid Debuging job | |
| 173 | 180 | { |
| 174 | 181 | const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying(); |
| 175 | 182 | task.addJob<DebugLightClusters>("DebugLightClusters", debugLightClustersInputs); |
| 176 | 183 | } |
| 177 | − | |
| 184 | + | |
| 185 | + const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeModel, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingFramebuffer)); | |
| 186 | + task.addJob<DrawHaze>("DrawHaze", drawHazeInputs); | |
| 187 | + | |
| 178 | 188 | const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); |
| 179 | 189 | |
| 190 | + // Add bloom | |
| 191 | + const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying(); | |
| 192 | + task.addJob<Bloom>("Bloom", bloomInputs); | |
| 193 | + | |
| 180 | 194 | // Lighting Buffer ready for tone mapping |
| 181 | 195 | const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying(); |
| 182 | 196 | task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs); |
| 183 | 197 | |
| 184 | − const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginOutlineRangeTimer", "Outline"); | |
| 185 | − const auto outlineInputs = DrawOutlineTask::Inputs(selectedItems, shapePlumber, deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying(); | |
| 186 | − task.addJob<DrawOutlineTask>("DrawOutline", outlineInputs); | |
| 187 | − task.addJob<EndGPURangeTimer>("EndOutlineRangeTimer", outlineRangeTimer); | |
| 198 | + const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginHighlightRangeTimer", "Highlight"); | |
| 199 | + // Select items that need to be outlined | |
| 200 | + const auto selectionBaseName = "contextOverlayHighlightList"; | |
| 201 | + const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents); | |
| 202 | + | |
| 203 | + const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying(); | |
| 204 | + task.addJob<DrawHighlightTask>("DrawHighlight", outlineInputs); | |
| 188 | 205 | |
| 189 | − { // DEbug the bounds of the rendered items, still look at the zbuffer | |
| 206 | + task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer); | |
| 207 | + | |
| 208 | + { // Debug the bounds of the rendered items, still look at the zbuffer | |
| 190 | 209 | task.addJob<DrawBounds>("DrawMetaBounds", metas); |
| 191 | 210 | task.addJob<DrawBounds>("DrawOpaqueBounds", opaques); |
| 192 | 211 | task.addJob<DrawBounds>("DrawTransparentBounds", transparents); |
| 193 | 212 | |
| 194 | 213 | task.addJob<DrawBounds>("DrawLightBounds", lights); |
| 195 | 214 | task.addJob<DrawBounds>("DrawZones", zones); |
| 215 | + const auto frustums = task.addJob<ExtractFrustums>("ExtractFrustums"); | |
| 216 | + const auto viewFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::VIEW_FRUSTUM); | |
| 217 | + const auto shadowFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::SHADOW_FRUSTUM); | |
| 218 | + task.addJob<DrawFrustum>("DrawViewFrustum", viewFrustum, glm::vec3(1.0f, 1.0f, 0.0f)); | |
| 219 | + task.addJob<DrawFrustum>("DrawShadowFrustum", shadowFrustum, glm::vec3(0.0f, 0.0f, 1.0f)); | |
| 220 | + | |
| 221 | + // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true | |
| 222 | + task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems); | |
| 196 | 223 | } |
| 197 | 224 | |
| 198 | 225 | // Layered Overlays |
| @@ -239,9 +266,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines | ||
| 239 | 266 | } |
| 240 | 267 | |
| 241 | 268 | task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform); |
| 242 | − | |
| 243 | − // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true | |
| 244 | − task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems); | |
| 245 | 269 | } |
| 246 | 270 | |
| 247 | 271 | // AA job to be revisited |
| @@ -443,10 +467,15 @@ void CompositeHUD::run(const RenderContextPointer& renderContext) { · 195 unmodified lines | ||
| 443 | 467 | assert(renderContext->args); |
| 444 | 468 | assert(renderContext->args->_context); |
| 445 | 469 | |
| 470 | + // We do not want to render HUD elements in secondary camera | |
| 471 | + if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) { | |
| 472 | + return; | |
| 473 | + } | |
| 474 | + | |
| 446 | 475 | // Grab the HUD texture |
| 447 | 476 | gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { |
| 448 | 477 | if (renderContext->args->_hudOperator) { |
| 449 | − renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture); | |
| 478 | + renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE); | |
| 450 | 479 | } |
| 451 | 480 | }); |
| 452 | 481 | } |
| @@ -459,6 +488,7 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 6 unmodified lines | ||
| 459 | 488 | auto blitFbo = renderArgs->_blitFramebuffer; |
| 460 | 489 | |
| 461 | 490 | if (!blitFbo) { |
| 491 | + qCWarning(renderutils) << "Blit::run - no blit frame buffer."; | |
| 462 | 492 | return; |
| 463 | 493 | } |
| 464 | 494 | |
| @@ -521,3 +551,32 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 56 unmodified lines | ||
| 521 | 551 | }); |
| 522 | 552 | } |
| 523 | 553 | |
| 554 | +void ExtractFrustums::run(const render::RenderContextPointer& renderContext, Output& output) { | |
| 555 | + assert(renderContext->args); | |
| 556 | + assert(renderContext->args->_context); | |
| 557 | + | |
| 558 | + RenderArgs* args = renderContext->args; | |
| 559 | + | |
| 560 | + // Return view frustum | |
| 561 | + auto& viewFrustum = output[VIEW_FRUSTUM].edit<ViewFrustumPointer>(); | |
| 562 | + if (!viewFrustum) { | |
| 563 | + viewFrustum = std::make_shared<ViewFrustum>(args->getViewFrustum()); | |
| 564 | + } else { | |
| 565 | + *viewFrustum = args->getViewFrustum(); | |
| 566 | + } | |
| 567 | + | |
| 568 | + // Return shadow frustum | |
| 569 | + auto& shadowFrustum = output[SHADOW_FRUSTUM].edit<ViewFrustumPointer>(); | |
| 570 | + auto lightStage = args->_scene->getStage<LightStage>(LightStage::getName()); | |
| 571 | + if (lightStage) { | |
| 572 | + auto globalShadow = lightStage->getCurrentKeyShadow(); | |
| 573 | + | |
| 574 | + if (globalShadow) { | |
| 575 | + shadowFrustum = globalShadow->getFrustum(); | |
| 576 | + } else { | |
| 577 | + shadowFrustum.reset(); | |
| 578 | + } | |
| 579 | + } else { | |
| 580 | + shadowFrustum.reset(); | |
| 581 | + } | |
| 582 | +} | |