History

Merging with upstream

samcake committed 8 years ago

Commit e0110ff2 parents ec93433 a5e671e746 files · +25281 −14034Browse files

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

Unified · Split

libraries/render-utils/src/RenderDeferredTask.cpp+85−26
@@ -36,15 +36,17 @@ · 35 unmodified lines
3636 #include "TextureCache.h"
3737 #include "ZoneRenderer.h"
3838 #include "FadeEffect.h"
39+#include "RenderUtilsLogging.h"
3940
4041 #include "AmbientOcclusionEffect.h"
4142 #include "AntialiasingEffect.h"
4243 #include "ToneMappingEffect.h"
4344 #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"
4748
49+#include <sstream>
4850
4951 using namespace render;
5052 extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
@@ -58,6 +60,18 @@ void RenderDeferredTask::configure(const Config& config) · 7 unmodified lines
5860 {
5961 }
6062
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+
6175 void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
6276 const auto& items = input.get<Input>();
6377 auto fadeEffect = DependencyManager::get<FadeEffect>();
@@ -98,15 +112,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 34 unmodified lines
98112 // draw a stencil mask in hidden regions of the framebuffer.
99113 task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer);
100114
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−
110115 // Render opaque objects in DeferredBuffer
111116 const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying();
112117 task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber);
@@ -153,11 +158,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines
153158 // Create the cluster grid of lights, cpu job for now
154159 const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget).asVarying();
155160 const auto lightClusters = task.addJob<LightClusteringPass>("LightClustering", lightClusteringPassInputs);
156−
157−
161+
162+ // Add haze model
163+ const auto hazeModel = task.addJob<FetchHazeStage>("HazeModel");
164+
158165 // DeferredBuffer is complete, now let's shade it into the LightingBuffer
159166 const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel,
160− surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters).asVarying();
167+ surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters, hazeModel).asVarying();
161168
162169 task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
163170
@@ -169,30 +176,50 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 5 unmodified lines
169176 const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).asVarying();
170177 task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);
171178
172− // LIght Cluster Grid Debuging job
179+ // Light Cluster Grid Debuging job
173180 {
174181 const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying();
175182 task.addJob<DebugLightClusters>("DebugLightClusters", debugLightClustersInputs);
176183 }
177−
184+
185+ const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeModel, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingFramebuffer));
186+ task.addJob<DrawHaze>("DrawHaze", drawHazeInputs);
187+
178188 const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing");
179189
190+ // Add bloom
191+ const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying();
192+ task.addJob<Bloom>("Bloom", bloomInputs);
193+
180194 // Lighting Buffer ready for tone mapping
181195 const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();
182196 task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
183197
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);
188205
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
190209 task.addJob<DrawBounds>("DrawMetaBounds", metas);
191210 task.addJob<DrawBounds>("DrawOpaqueBounds", opaques);
192211 task.addJob<DrawBounds>("DrawTransparentBounds", transparents);
193212
194213 task.addJob<DrawBounds>("DrawLightBounds", lights);
195214 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);
196223 }
197224
198225 // Layered Overlays
@@ -239,9 +266,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines
239266 }
240267
241268 task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
242−
243− // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true
244− task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems);
245269 }
246270
247271 // AA job to be revisited
@@ -443,10 +467,15 @@ void CompositeHUD::run(const RenderContextPointer& renderContext) { · 195 unmodified lines
443467 assert(renderContext->args);
444468 assert(renderContext->args->_context);
445469
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+
446475 // Grab the HUD texture
447476 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
448477 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);
450479 }
451480 });
452481 }
@@ -459,6 +488,7 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 6 unmodified lines
459488 auto blitFbo = renderArgs->_blitFramebuffer;
460489
461490 if (!blitFbo) {
491+ qCWarning(renderutils) << "Blit::run - no blit frame buffer.";
462492 return;
463493 }
464494
@@ -521,3 +551,32 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 56 unmodified lines
521551 });
522552 }
523553
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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t