Showing the changes to libraries/render-utils/src/RenderShadowTask.cpp (1 of 18 files). Show all
Unified · Split
| @@ -59,11 +59,14 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 58 unmodified lines | ||
| 59 | 59 | // 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 |
| 60 | 60 | // Fetch the current frame stacks from all the stages |
| 61 | 61 | // 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); | |
| 63 | 66 | |
| 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); | |
| 67 | 70 | // Fetch and cull the items from the scene |
| 68 | 71 | |
| 69 | 72 | 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 | ||
| 75 | 78 | |
| 76 | 79 | // Cull objects that are not visible in camera view. Hopefully the cull functor only performs LOD culling, not |
| 77 | 80 | // 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); | |
| 79 | 82 | const auto applyFunctorInputs = ApplyCullFunctorOnItemBounds::Inputs(shadowItems, cameraFrustum).asVarying(); |
| 80 | 83 | const auto culledShadowItems = task.addJob<ApplyCullFunctorOnItemBounds>("ShadowCullCamera", applyFunctorInputs, cameraCullFunctor); |
| 81 | 84 | |
| @@ -122,7 +125,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende · 40 unmodified lines | ||
| 122 | 125 | task.addJob<RenderShadowTeardown>("ShadowTeardown", setupOutput); |
| 123 | 126 | |
| 124 | 127 | |
| 125 | − output = Output(cascadeSceneBBoxes, setupOutput.getN<RenderShadowSetup::Outputs>(3)); | |
| 128 | + output = Output(cascadeSceneBBoxes, setupOutput.getN<RenderShadowSetup::Output>(3)); | |
| 126 | 129 | |
| 127 | 130 | } |
| 128 | 131 | |
| @@ -341,12 +344,19 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) { · 212 unmodified lines | ||
| 341 | 344 | _bias[cascadeIndex]._slope = value * value * value * 0.01f; |
| 342 | 345 | } |
| 343 | 346 | |
| 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) { | |
| 345 | 348 | // Abort all jobs if not casting shadows |
| 346 | 349 | auto lightStage = renderContext->_scene->getStage<LightStage>(); |
| 347 | − auto lightFrame = *input; | |
| 348 | 350 | 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()) { | |
| 350 | 360 | renderContext->taskFlow.abortTask(); |
| 351 | 361 | return; |
| 352 | 362 | } |
| @@ -360,16 +370,12 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c · 7 unmodified lines | ||
| 360 | 370 | *_cameraFrustum = args->getViewFrustum(); |
| 361 | 371 | output.edit2() = _cameraFrustum; |
| 362 | 372 | |
| 363 | − // Clear previous shadow frame | |
| 364 | 373 | if (!_globalShadowObject) { |
| 365 | 374 | _globalShadowObject = std::make_shared<LightStage::Shadow>(graphics::LightPointer(), 100.f, 4); |
| 366 | 375 | } |
| 367 | − _shadowFrameCache->_objects.clear(); | |
| 368 | 376 | |
| 369 | 377 | const auto theGlobalLight = lightStage->getCurrentKeyLight(lightFrame); |
| 370 | 378 | if (theGlobalLight && theGlobalLight->getCastShadows()) { |
| 371 | − //const auto theGlobalShadow = lightStage->getCurrentKeyShadow(lightFrame); | |
| 372 | − //if (theGlobalShadow) { | |
| 373 | 379 | _globalShadowObject->setLight(theGlobalLight); |
| 374 | 380 | _globalShadowObject->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); |
| 375 | 381 | |
| @@ -435,8 +441,6 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c · 59 unmodified lines | ||
| 435 | 441 | queryResolution.x = int(queryResolution.x * _coarseShadowFrustum->getWidth() / firstCascadeFrustum->getWidth()); |
| 436 | 442 | queryResolution.y = int(queryResolution.y * _coarseShadowFrustum->getHeight() / firstCascadeFrustum->getHeight()); |
| 437 | 443 | output.edit1() = queryResolution; |
| 438 | − | |
| 439 | − output.edit3() = _shadowFrameCache; | |
| 440 | 444 | } |
| 441 | 445 | } |
| 442 | 446 | |