Ejemplo n.º 1
0
void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) {
    auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
    const auto globalShadow = lightStage->getShadow(0);

    // Cache old render args
    RenderArgs* args = renderContext->args;
    output = args->_renderMode;

    auto nearClip = args->getViewFrustum().getNearClip();
    float nearDepth = -args->_boomOffset.z;
    const int SHADOW_FAR_DEPTH = 20;
    globalShadow->setKeylightFrustum(args->getViewFrustum(), nearDepth, nearClip + SHADOW_FAR_DEPTH);

    // Set the keylight render args
    args->pushViewFrustum(*(globalShadow->getFrustum()));
    args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;
}
Ejemplo n.º 2
0
void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
    assert(sceneContext);
    RenderArgs* args = renderContext->args;

    // sanity checks
    if (!sceneContext->_scene || !args) {
        return;
    }

    auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
    const auto globalShadow = lightStage->getShadow(0);

    // If the global light is not set, bail
    if (!globalShadow) {
        return;
    }

    // Cache old render args
    RenderArgs::RenderMode mode = args->_renderMode;

    auto nearClip = args->getViewFrustum().getNearClip();
    float nearDepth = -args->_boomOffset.z;
    const int SHADOW_FAR_DEPTH = 20;
    globalShadow->setKeylightFrustum(args->getViewFrustum(), nearDepth, nearClip + SHADOW_FAR_DEPTH);

    // Set the keylight render args
    args->pushViewFrustum(*(globalShadow->getFrustum()));
    args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;

    // TODO: Allow runtime manipulation of culling ShouldRenderFunctor

    for (auto job : _jobs) {
        job.run(sceneContext, renderContext);
    }

    // Reset the render args
    args->popViewFrustum();
    args->_renderMode = mode;
};