Showing the changes to libraries/render-utils/src/RenderShadowTask.cpp (1 of 30 files). Show all
Unified · Split
| @@ -218,7 +218,10 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 217 unmodified lines | ||
| 218 | 218 | const auto setupOutput = task.addJob<RenderShadowSetup>("ShadowSetup"); |
| 219 | 219 | const auto queryResolution = setupOutput.getN<RenderShadowSetup::Outputs>(2); |
| 220 | 220 | // 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 | 225 | const auto fetchInput = FetchSpatialTree::Inputs(shadowCasterFilter, queryResolution).asVarying(); |
| 223 | 226 | const auto shadowSelection = task.addJob<FetchSpatialTree>("FetchShadowTree", fetchInput); |
| 224 | 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 | |
| 299 | 302 | void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) { |
| 303 | + // Abort all jobs if not casting shadows | |
| 300 | 304 | auto lightStage = renderContext->_scene->getStage<LightStage>(); |
| 301 | 305 | assert(lightStage); |
| 306 | + if (!lightStage->getCurrentKeyLight() || !lightStage->getCurrentKeyLight()->getCastShadows()) { | |
| 307 | + renderContext->taskFlow.abortTask(); | |
| 308 | + return; | |
| 309 | + } | |
| 310 | + | |
| 302 | 311 | // Cache old render args |
| 303 | 312 | RenderArgs* args = renderContext->args; |
| 304 | 313 | |
| @@ -378,12 +387,13 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O · 73 unmodified lines | ||
| 378 | 387 | void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, Outputs& output) { |
| 379 | 388 | auto lightStage = renderContext->_scene->getStage<LightStage>(); |
| 380 | 389 | assert(lightStage); |
| 390 | + | |
| 381 | 391 | // Cache old render args |
| 382 | 392 | RenderArgs* args = renderContext->args; |
| 383 | 393 | |
| 384 | 394 | const auto globalShadow = lightStage->getCurrentKeyShadow(); |
| 385 | 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 | 398 | // Set the keylight render args |
| 389 | 399 | auto& cascade = globalShadow->getCascade(_cascadeIndex); |