Showing the changes to libraries/render-utils/src/RenderDeferredTask.cpp (1 of 596 files). Show all
Unified · Split
| @@ -35,16 +35,17 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "TextureCache.h" |
| 36 | 36 | #include "ZoneRenderer.h" |
| 37 | 37 | #include "FadeEffect.h" |
| 38 | +#include "RenderUtilsLogging.h" | |
| 38 | 39 | |
| 39 | 40 | #include "AmbientOcclusionEffect.h" |
| 40 | 41 | #include "AntialiasingEffect.h" |
| 41 | 42 | #include "ToneMappingEffect.h" |
| 42 | 43 | #include "SubsurfaceScattering.h" |
| 43 | 44 | #include "DrawHaze.h" |
| 44 | −#include "OutlineEffect.h" | |
| 45 | − | |
| 46 | −#include <gpu/StandardShaderLib.h> | |
| 45 | +#include "BloomEffect.h" | |
| 46 | +#include "HighlightEffect.h" | |
| 47 | 47 | |
| 48 | +#include <sstream> | |
| 48 | 49 | |
| 49 | 50 | using namespace render; |
| 50 | 51 | extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false); |
| @@ -58,6 +59,18 @@ void RenderDeferredTask::configure(const Config& config) · 7 unmodified lines | ||
| 58 | 59 | { |
| 59 | 60 | } |
| 60 | 61 | |
| 62 | +const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName, | |
| 63 | + const render::Varying& metas, | |
| 64 | + const render::Varying& opaques, | |
| 65 | + const render::Varying& transparents) { | |
| 66 | + const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying(); | |
| 67 | + const auto selectedMetas = task.addJob<SelectItems>("MetaSelection", selectMetaInput, selectionName); | |
| 68 | + const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas, std::string()).asVarying(); | |
| 69 | + const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput, selectionName); | |
| 70 | + const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, std::string()).asVarying(); | |
| 71 | + return task.addJob<SelectItems>("TransparentSelection", selectItemInput, selectionName); | |
| 72 | +} | |
| 73 | + | |
| 61 | 74 | void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { |
| 62 | 75 | const auto& items = input.get<Input>(); |
| 63 | 76 | auto fadeEffect = DependencyManager::get<FadeEffect>(); |
| @@ -95,15 +108,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 31 unmodified lines | ||
| 95 | 108 | // draw a stencil mask in hidden regions of the framebuffer. |
| 96 | 109 | task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer); |
| 97 | 110 | |
| 98 | − // Select items that need to be outlined | |
| 99 | − const auto selectionName = "contextOverlayHighlightList"; | |
| 100 | − const auto selectMetaInput = SelectItems::Inputs(metas, Varying()).asVarying(); | |
| 101 | − const auto selectedMetas = task.addJob<SelectItems>("PassTestMetaSelection", selectMetaInput, selectionName); | |
| 102 | − const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas).asVarying(); | |
| 103 | − const auto selectedMetasAndOpaques = task.addJob<SelectItems>("PassTestOpaqueSelection", selectMetaAndOpaqueInput, selectionName); | |
| 104 | − const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques).asVarying(); | |
| 105 | − const auto selectedItems = task.addJob<SelectItems>("PassTestTransparentSelection", selectItemInput, selectionName); | |
| 106 | − | |
| 107 | 111 | // Render opaque objects in DeferredBuffer |
| 108 | 112 | const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying(); |
| 109 | 113 | task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber); |
| @@ -166,7 +170,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 56 unmodified lines | ||
| 166 | 170 | const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).asVarying(); |
| 167 | 171 | task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber); |
| 168 | 172 | |
| 169 | − // LIght Cluster Grid Debuging job | |
| 173 | + // Light Cluster Grid Debuging job | |
| 170 | 174 | { |
| 171 | 175 | const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying(); |
| 172 | 176 | task.addJob<DebugLightClusters>("DebugLightClusters", debugLightClustersInputs); |
| @@ -174,44 +178,50 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 1 unmodified line | ||
| 174 | 178 | |
| 175 | 179 | const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); |
| 176 | 180 | |
| 181 | + // Add bloom | |
| 182 | + const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying(); | |
| 183 | + task.addJob<Bloom>("Bloom", bloomInputs); | |
| 184 | + | |
| 177 | 185 | // Lighting Buffer ready for tone mapping |
| 178 | 186 | const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying(); |
| 179 | 187 | task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs); |
| 180 | 188 | |
| 181 | − const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginOutlineRangeTimer", "Outline"); | |
| 182 | − const auto outlineInputs = DrawOutlineTask::Inputs(selectedItems, shapePlumber, deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying(); | |
| 183 | − task.addJob<DrawOutlineTask>("DrawOutline", outlineInputs); | |
| 184 | − task.addJob<EndGPURangeTimer>("EndOutlineRangeTimer", outlineRangeTimer); | |
| 189 | + const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginHighlightRangeTimer", "Highlight"); | |
| 190 | + // Select items that need to be outlined | |
| 191 | + const auto selectionBaseName = "contextOverlayHighlightList"; | |
| 192 | + const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents); | |
| 193 | + | |
| 194 | + const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying(); | |
| 195 | + task.addJob<DrawHighlightTask>("DrawHighlight", outlineInputs); | |
| 185 | 196 | |
| 186 | − { // DEbug the bounds of the rendered items, still look at the zbuffer | |
| 197 | + task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer); | |
| 198 | + | |
| 199 | + { // Debug the bounds of the rendered items, still look at the zbuffer | |
| 187 | 200 | task.addJob<DrawBounds>("DrawMetaBounds", metas); |
| 188 | 201 | task.addJob<DrawBounds>("DrawOpaqueBounds", opaques); |
| 189 | 202 | task.addJob<DrawBounds>("DrawTransparentBounds", transparents); |
| 190 | 203 | |
| 191 | 204 | task.addJob<DrawBounds>("DrawLightBounds", lights); |
| 192 | 205 | task.addJob<DrawBounds>("DrawZones", zones); |
| 193 | − } | |
| 194 | − | |
| 195 | − // Layered Overlays | |
| 196 | − const auto filteredOverlaysOpaque = task.addJob<FilterLayeredItems>("FilterOverlaysLayeredOpaque", overlayOpaques, Item::LAYER_3D_FRONT); | |
| 197 | − const auto filteredOverlaysTransparent = task.addJob<FilterLayeredItems>("FilterOverlaysLayeredTransparent", overlayTransparents, Item::LAYER_3D_FRONT); | |
| 198 | − const auto overlaysInFrontOpaque = filteredOverlaysOpaque.getN<FilterLayeredItems::Outputs>(0); | |
| 199 | − const auto overlaysInFrontTransparent = filteredOverlaysTransparent.getN<FilterLayeredItems::Outputs>(0); | |
| 200 | − | |
| 201 | − const auto overlayInFrontOpaquesInputs = DrawOverlay3D::Inputs(overlaysInFrontOpaque, lightingModel).asVarying(); | |
| 202 | − const auto overlayInFrontTransparentsInputs = DrawOverlay3D::Inputs(overlaysInFrontTransparent, lightingModel).asVarying(); | |
| 203 | − task.addJob<DrawOverlay3D>("DrawOverlayInFrontOpaque", overlayInFrontOpaquesInputs, true); | |
| 204 | − task.addJob<DrawOverlay3D>("DrawOverlayInFrontTransparent", overlayInFrontTransparentsInputs, false); | |
| 206 | + const auto frustums = task.addJob<ExtractFrustums>("ExtractFrustums"); | |
| 207 | + const auto viewFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::VIEW_FRUSTUM); | |
| 208 | + task.addJob<DrawFrustum>("DrawViewFrustum", viewFrustum, glm::vec3(1.0f, 1.0f, 0.0f)); | |
| 209 | + for (auto i = 0; i < ExtractFrustums::SHADOW_CASCADE_FRUSTUM_COUNT; i++) { | |
| 210 | + const auto shadowFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::SHADOW_CASCADE0_FRUSTUM+i); | |
| 211 | + float tint = 1.0f - i / float(ExtractFrustums::SHADOW_CASCADE_FRUSTUM_COUNT - 1); | |
| 212 | + char jobName[64]; | |
| 213 | + sprintf(jobName, "DrawShadowFrustum%d", i); | |
| 214 | + task.addJob<DrawFrustum>(jobName, shadowFrustum, glm::vec3(0.0f, tint, 1.0f)); | |
| 215 | + } | |
| 205 | 216 | |
| 206 | − { // Debug the bounds of the rendered Overlay items that are marked drawInFront, still look at the zbuffer | |
| 207 | − task.addJob<DrawBounds>("DrawOverlayInFrontOpaqueBounds", overlaysInFrontOpaque); | |
| 208 | − task.addJob<DrawBounds>("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent); | |
| 217 | + // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true | |
| 218 | + task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems); | |
| 209 | 219 | } |
| 210 | 220 | |
| 211 | 221 | // Debugging stages |
| 212 | 222 | { |
| 213 | 223 | // Debugging Deferred buffer job |
| 214 | − const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer)); | |
| 224 | + const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(deferredFramebuffer, linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, deferredFrameTransform)); | |
| 215 | 225 | task.addJob<DebugDeferredBuffer>("DebugDeferredBuffer", debugFramebuffers); |
| 216 | 226 | |
| 217 | 227 | const auto debugSubsurfaceScatteringInputs = DebugSubsurfaceScattering::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, |
| @@ -236,9 +246,22 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 18 unmodified lines | ||
| 236 | 246 | } |
| 237 | 247 | |
| 238 | 248 | task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform); |
| 239 | − | |
| 240 | − // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true | |
| 241 | − task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems); | |
| 249 | + } | |
| 250 | + | |
| 251 | + // Layered Overlays | |
| 252 | + const auto filteredOverlaysOpaque = task.addJob<FilterLayeredItems>("FilterOverlaysLayeredOpaque", overlayOpaques, Item::LAYER_3D_FRONT); | |
| 253 | + const auto filteredOverlaysTransparent = task.addJob<FilterLayeredItems>("FilterOverlaysLayeredTransparent", overlayTransparents, Item::LAYER_3D_FRONT); | |
| 254 | + const auto overlaysInFrontOpaque = filteredOverlaysOpaque.getN<FilterLayeredItems::Outputs>(0); | |
| 255 | + const auto overlaysInFrontTransparent = filteredOverlaysTransparent.getN<FilterLayeredItems::Outputs>(0); | |
| 256 | + | |
| 257 | + const auto overlayInFrontOpaquesInputs = DrawOverlay3D::Inputs(overlaysInFrontOpaque, lightingModel).asVarying(); | |
| 258 | + const auto overlayInFrontTransparentsInputs = DrawOverlay3D::Inputs(overlaysInFrontTransparent, lightingModel).asVarying(); | |
| 259 | + task.addJob<DrawOverlay3D>("DrawOverlayInFrontOpaque", overlayInFrontOpaquesInputs, true); | |
| 260 | + task.addJob<DrawOverlay3D>("DrawOverlayInFrontTransparent", overlayInFrontTransparentsInputs, false); | |
| 261 | + | |
| 262 | + { // Debug the bounds of the rendered Overlay items that are marked drawInFront, still look at the zbuffer | |
| 263 | + task.addJob<DrawBounds>("DrawOverlayInFrontOpaqueBounds", overlaysInFrontOpaque); | |
| 264 | + task.addJob<DrawBounds>("DrawOverlayInFrontTransparentBounds", overlaysInFrontTransparent); | |
| 242 | 265 | } |
| 243 | 266 | |
| 244 | 267 | // AA job to be revisited |
| @@ -445,6 +468,11 @@ void CompositeHUD::run(const RenderContextPointer& renderContext) { · 200 unmodified lines | ||
| 445 | 468 | assert(renderContext->args); |
| 446 | 469 | assert(renderContext->args->_context); |
| 447 | 470 | |
| 471 | + // We do not want to render HUD elements in secondary camera | |
| 472 | + if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) { | |
| 473 | + return; | |
| 474 | + } | |
| 475 | + | |
| 448 | 476 | // Grab the HUD texture |
| 449 | 477 | gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { |
| 450 | 478 | if (renderContext->args->_hudOperator) { |
| @@ -461,6 +489,7 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 10 unmodified lines | ||
| 461 | 489 | auto blitFbo = renderArgs->_blitFramebuffer; |
| 462 | 490 | |
| 463 | 491 | if (!blitFbo) { |
| 492 | + qCWarning(renderutils) << "Blit::run - no blit frame buffer."; | |
| 464 | 493 | return; |
| 465 | 494 | } |
| 466 | 495 | |
| @@ -523,3 +552,35 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 56 unmodified lines | ||
| 523 | 552 | }); |
| 524 | 553 | } |
| 525 | 554 | |
| 555 | +void ExtractFrustums::run(const render::RenderContextPointer& renderContext, Output& output) { | |
| 556 | + assert(renderContext->args); | |
| 557 | + assert(renderContext->args->_context); | |
| 558 | + | |
| 559 | + RenderArgs* args = renderContext->args; | |
| 560 | + | |
| 561 | + // Return view frustum | |
| 562 | + auto& viewFrustum = output[VIEW_FRUSTUM].edit<ViewFrustumPointer>(); | |
| 563 | + if (!viewFrustum) { | |
| 564 | + viewFrustum = std::make_shared<ViewFrustum>(args->getViewFrustum()); | |
| 565 | + } else { | |
| 566 | + *viewFrustum = args->getViewFrustum(); | |
| 567 | + } | |
| 568 | + | |
| 569 | + // Return shadow frustum | |
| 570 | + auto lightStage = args->_scene->getStage<LightStage>(LightStage::getName()); | |
| 571 | + for (auto i = 0; i < SHADOW_CASCADE_FRUSTUM_COUNT; i++) { | |
| 572 | + auto& shadowFrustum = output[SHADOW_CASCADE0_FRUSTUM+i].edit<ViewFrustumPointer>(); | |
| 573 | + if (lightStage) { | |
| 574 | + auto globalShadow = lightStage->getCurrentKeyShadow(); | |
| 575 | + | |
| 576 | + if (globalShadow && i<(int)globalShadow->getCascadeCount()) { | |
| 577 | + auto& cascade = globalShadow->getCascade(i); | |
| 578 | + shadowFrustum = cascade.getFrustum(); | |
| 579 | + } else { | |
| 580 | + shadowFrustum.reset(); | |
| 581 | + } | |
| 582 | + } else { | |
| 583 | + shadowFrustum.reset(); | |
| 584 | + } | |
| 585 | + } | |
| 586 | +} | |