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
218 const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup");218 const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup");
219 const auto queryResolution = setupOutput.getN<RenderShadowSetup::Outputs>(2);219 const auto queryResolution = setupOutput.getN<RenderShadowSetup::Outputs>(2);
220 // Fetch and cull the items from the scene220 // 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
222 const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterFilter, queryResolution).asVarying();225 const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterFilter, queryResolution).asVarying();
223 const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);226 const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput);
224 const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterFilter).asVarying();227 const auto selectionInputs = FetchSpatialSelection::Inputs(shadowSelection, shadowCasterFilter).asVarying();
@@ -297,8 +300,14 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) { · 72 unmodified lines
297}300}
298 301
299void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {302void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {
303 // Abort all jobs if not casting shadows
300 auto lightStage = renderContext->_scene->getStage<LightStage>();304 auto lightStage = renderContext->_scene->getStage<LightStage>();
301 assert(lightStage);305 assert(lightStage);
306 if (!lightStage->getCurrentKeyLight() || !lightStage->getCurrentKeyLight()->getCastShadows()) {
307 renderContext->taskFlow.abortTask();
308 return;
309 }
310
302 // Cache old render args311 // Cache old render args
303 RenderArgs* args = renderContext->args;312 RenderArgs* args = renderContext->args;
304 313
@@ -378,12 +387,13 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O · 73 unmodified lines
378void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {387void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) {
379 auto lightStage = renderContext->_scene->getStage<LightStage>();388 auto lightStage = renderContext->_scene->getStage<LightStage>();
380 assert(lightStage);389 assert(lightStage);
390
381 // Cache old render args391 // Cache old render args
382 RenderArgs* args = renderContext->args;392 RenderArgs* args = renderContext->args;
383 393
384 const auto globalShadow = lightStage->getCurrentKeyShadow();394 const auto globalShadow = lightStage->getCurrentKeyShadow();
385 if (globalShadow && _cascadeIndex<globalShadow->getCascadeCount()) {395 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();
387 397
388 // Set the keylight render args398 // Set the keylight render args
389 auto& cascade = globalShadow->getCascade(_cascadeIndex);399 auto& cascade = globalShadow->getCascade(_cascadeIndex);