History

Shadows are completely working with settings on both pipeline

sam gateau committed 7 years ago

Commit 237fb4d1 parent 5a6f30b18 files · +284 −96Browse files

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

Unified · Split

libraries/render-utils/src/RenderShadowTask.cpp+19−15
@@ -59,11 +59,14 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 58 unmodified lines
5959 // FIXME: calling this here before the zones/lights are drawn during the deferred/forward passes means we're actually using the frames from the previous draw
6060 // Fetch the current frame stacks from all the stages
6161 // Starting with the Light Frame genreated in previous tasks
62− const auto& lightFrame = input;
62+
63+ const auto& lightFrame = input.getN<Input>(0);
64+
65+ const auto& lightingModel = input.getN<Input>(1);
6366
64− const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup", lightFrame);
65− const auto queryResolution = setupOutput.getN<RenderShadowSetup::Outputs>(1);
66− const auto shadowFrame = setupOutput.getN<RenderShadowSetup::Outputs>(3);
67+ const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup", input);
68+ const auto queryResolution = setupOutput.getN<RenderShadowSetup::Output>(1);
69+ const auto shadowFrame = setupOutput.getN<RenderShadowSetup::Output>(3);
6770 // Fetch and cull the items from the scene
6871
6972 static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask);
@@ -75,7 +78,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 5 unmodified lines
7578
7679 // Cull objects that are not visible in camera view. Hopefully the cull functor only performs LOD culling, not
7780 // frustum culling or this will make shadow casters out of the camera frustum disappear.
78− const auto cameraFrustum = setupOutput.getN<RenderShadowSetup::Outputs>(2);
81+ const auto cameraFrustum = setupOutput.getN<RenderShadowSetup::Output>(2);
7982 const auto applyFunctorInputs = ApplyCullFunctorOnItemBounds::Inputs(shadowItems, cameraFrustum).asVarying();
8083 const auto culledShadowItems = task.addJob<ApplyCullFunctorOnItemBounds>("ShadowCullCamera", applyFunctorInputs, cameraCullFunctor);
8184
@@ -122,7 +125,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 40 unmodified lines
122125 task.addJob<RenderShadowTeardown>("ShadowTeardown", setupOutput);
123126
124127
125− output = Output(cascadeSceneBBoxes, setupOutput.getN<RenderShadowSetup::Outputs>(3));
128+ output = Output(cascadeSceneBBoxes, setupOutput.getN<RenderShadowSetup::Output>(3));
126129
127130 }
128131
@@ -341,12 +344,19 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) { · 212 unmodified lines
341344 _bias[cascadeIndex]._slope = value * value * value * 0.01f;
342345 }
343346
344−void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) {
347+void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Input& input, Output& output) {
345348 // Abort all jobs if not casting shadows
346349 auto lightStage = renderContext->_scene->getStage<LightStage>();
347− auto lightFrame = *input;
348350 assert(lightStage);
349− if (!lightStage->getCurrentKeyLight(lightFrame) || !lightStage->getCurrentKeyLight(lightFrame)->getCastShadows()) {
351+
352+ const auto lightFrame = *input.get0();
353+ const auto lightingModel = input.get1();
354+
355+ // Clear previous shadow frame always
356+ _shadowFrameCache->_objects.clear();
357+ output.edit3() = _shadowFrameCache;
358+
359+ if (!lightingModel->isShadowEnabled() || !lightStage->getCurrentKeyLight(lightFrame) || !lightStage->getCurrentKeyLight(lightFrame)->getCastShadows()) {
350360 renderContext->taskFlow.abortTask();
351361 return;
352362 }
@@ -360,16 +370,12 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c · 7 unmodified lines
360370 *_cameraFrustum = args->getViewFrustum();
361371 output.edit2() = _cameraFrustum;
362372
363− // Clear previous shadow frame
364373 if (!_globalShadowObject) {
365374 _globalShadowObject = std::make_shared<LightStage::Shadow>(graphics::LightPointer(), 100.f, 4);
366375 }
367− _shadowFrameCache->_objects.clear();
368376
369377 const auto theGlobalLight = lightStage->getCurrentKeyLight(lightFrame);
370378 if (theGlobalLight && theGlobalLight->getCastShadows()) {
371− //const auto theGlobalShadow = lightStage->getCurrentKeyShadow(lightFrame);
372− //if (theGlobalShadow) {
373379 _globalShadowObject->setLight(theGlobalLight);
374380 _globalShadowObject->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);
375381
@@ -435,8 +441,6 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c · 59 unmodified lines
435441 queryResolution.x = int(queryResolution.x * _coarseShadowFrustum->getWidth() / firstCascadeFrustum->getWidth());
436442 queryResolution.y = int(queryResolution.y * _coarseShadowFrustum->getHeight() / firstCascadeFrustum->getHeight());
437443 output.edit1() = queryResolution;
438−
439− output.edit3() = _shadowFrameCache;
440444 }
441445 }
442446

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