History

Revert "Revert "Mirrors + Portals""

Dale Glass committed 2 years ago

Commit e7591d61 parent b33d35c81 files · +1047 −263Browse files

Showing the changes to libraries/render-utils/src/RenderDeferredTask.cpp (1 of 81 files). Show all

Unified · Split

libraries/render-utils/src/RenderDeferredTask.cpp+23−10
@@ -100,11 +100,14 @@ void RenderDeferredTask::configure(const Config& config) { · 99 unmodified lines
100100 preparePrimaryBufferConfig->setResolutionScale(config.resolutionScale);
101101 }
102102
103−void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
104− auto fadeEffect = DependencyManager::get<FadeEffect>();
103+void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, size_t depth) {
104+ static auto fadeEffect = DependencyManager::get<FadeEffect>();
105105 // Prepare the ShapePipelines
106− ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
107− initDeferredPipelines(*shapePlumber, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
106+ static ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
107+ static std::once_flag once;
108+ std::call_once(once, [] {
109+ initDeferredPipelines(*shapePlumber, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
110+ });
108111
109112 const auto& inputs = input.get<Input>();
110113
@@ -116,6 +119,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 5 unmodified lines
116119 // Extract opaques / transparents / lights / metas / layered / background
117120 const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE];
118121 const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE];
122+ const auto& mirrors = items[RenderFetchCullSortTask::MIRROR];
119123 const auto& inFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE];
120124 const auto& inFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE];
121125 const auto& hudOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE];
@@ -139,7 +143,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 17 unmodified lines
139143 // Shadow Stage Frame
140144 const auto shadowFrame = shadowTaskOutputs[1];
141145
142−
143146 fadeEffect->build(task, opaques);
144147
145148 const auto jitter = task.addJob<JitterSample>("JitterCam");
@@ -154,6 +157,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 8 unmodified lines
154157 const auto prepareDeferredOutputs = task.addJob<PrepareDeferred>("PrepareDeferred", prepareDeferredInputs);
155158 const auto deferredFramebuffer = prepareDeferredOutputs.getN<PrepareDeferred::Outputs>(0);
156159 const auto lightingFramebuffer = prepareDeferredOutputs.getN<PrepareDeferred::Outputs>(1);
160+ const auto mirrorTargetFramebuffer = prepareDeferredOutputs.getN<PrepareDeferred::Outputs>(2);
157161
158162 // draw a stencil mask in hidden regions of the framebuffer.
159163 task.addJob<PrepareStencil>("PrepareStencil", scaledPrimaryFramebuffer);
@@ -162,6 +166,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 2 unmodified lines
162166 const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel, jitter).asVarying();
163167 task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber);
164168
169+ if (depth < RenderMirrorTask::MAX_MIRROR_DEPTH) {
170+ const auto mirrorInputs = RenderMirrorTask::Inputs(mirrors, mirrorTargetFramebuffer, jitter).asVarying();
171+ for (size_t i = 0; i < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; i++) {
172+ task.addJob<RenderMirrorTask>("RenderMirrorTask" + std::to_string(i) + "Depth" + std::to_string(depth), mirrorInputs, i, cullFunctor, depth);
173+ }
174+ }
175+
165176 // Opaque all rendered
166177
167178 // Linear Depth Pass
@@ -234,7 +245,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 66 unmodified lines
234245
235246 // Lighting Buffer ready for tone mapping
236247 const auto toneMappingInputs = ToneMapAndResample::Input(lightingFramebuffer, destFramebuffer).asVarying();
237− const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapping", toneMappingInputs);
248+ const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapping", toneMappingInputs, depth);
238249
239250 // Debugging task is happening in the "over" layer after tone mapping and just before HUD
240251 { // Debug the bounds of the rendered items, still look at the zbuffer
@@ -398,8 +409,12 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input · 157 unmodified lines
398409 // Status icon rendering job
399410 {
400411 // Grab a texture map representing the different status icons and assign that to the drawStatusJob
401− auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
402− auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath, image::TextureUsage::STRICT_TEXTURE);
412+ static gpu::TexturePointer statusIconMap;
413+ static std::once_flag once;
414+ std::call_once(once, [] {
415+ auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
416+ statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath, image::TextureUsage::STRICT_TEXTURE);
417+ });
403418 const auto drawStatusInputs = DrawStatus::Input(opaques, jitter).asVarying();
404419 task.addJob<DrawStatus>("DrawStatus", drawStatusInputs, DrawStatus(statusIconMap));
405420 }
@@ -407,8 +422,6 @@ void RenderDeferredTaskDebug::build(JobModel& task, const render::Varying& input · 1 unmodified line
407422 const auto debugZoneInputs = DebugZoneLighting::Inputs(deferredFrameTransform, lightFrame, backgroundFrame).asVarying();
408423 task.addJob<DebugZoneLighting>("DrawZoneStack", debugZoneInputs);
409424 }
410−
411−
412425 }
413426
414427 gpu::FramebufferPointer PreparePrimaryFramebuffer::createFramebuffer(const char* name, const glm::uvec2& frameSize) {