History

Re-implemented shadow controls.

NissimHadar committed 8 years ago

Commit 0f2cf8e1 parent d888e7f30 files · +269 −95Browse files

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

Unified · Split

libraries/render-utils/src/RenderShadowTask.cpp+12−2
@@ -218,7 +218,10 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 217 unmodified lines
218218 const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup");
219219 const auto queryResolution = setupOutput.getN<RenderShadowSetup::Outputs>(2);
220220 // Fetch and cull the items from the scene
221− static const auto shadowCasterFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask);
221+
222+ // Enable models to not cast shadows (otherwise, models will always cast shadows)
223+ static const auto shadowCasterFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask).withShadowCaster();
224+
222225 const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterFilter, queryResolution).asVarying();
223226 const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);
224227 const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterFilter).asVarying();
@@ -297,8 +300,14 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) { · 72 unmodified lines
297300 }
298301
299302 void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {
303+ // Abort all jobs if not casting shadows
300304 auto lightStage = renderContext->_scene->getStage<LightStage>();
301305 assert(lightStage);
306+ if (!lightStage->getCurrentKeyLight() || !lightStage->getCurrentKeyLight()->getCastShadows()) {
307+ renderContext->taskFlow.abortTask();
308+ return;
309+ }
310+
302311 // Cache old render args
303312 RenderArgs* args = renderContext->args;
304313
@@ -378,12 +387,13 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O · 73 unmodified lines
378387 void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {
379388 auto lightStage = renderContext->_scene->getStage<LightStage>();
380389 assert(lightStage);
390+
381391 // Cache old render args
382392 RenderArgs* args = renderContext->args;
383393
384394 const auto globalShadow = lightStage->getCurrentKeyShadow();
385395 if (globalShadow && _cascadeIndex<globalShadow->getCascadeCount()) {
386− output.edit0() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(_tagBits, _tagMask);
396+ output.edit0() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(_tagBits, _tagMask).withShadowCaster();
387397
388398 // Set the keylight render args
389399 auto& cascade = globalShadow->getCascade(_cascadeIndex);