mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:48:09 +02:00
mv shadow task setup to jobs
This commit is contained in:
parent
08cfd8a40e
commit
dbf4f2d23b
2 changed files with 30 additions and 12 deletions
|
@ -115,6 +115,8 @@ RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) {
|
||||||
skinProgram, state);
|
skinProgram, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto cachedMode = addJob<RenderShadowSetup>("Setup");
|
||||||
|
|
||||||
// CPU jobs:
|
// CPU jobs:
|
||||||
// Fetch and cull the items from the scene
|
// Fetch and cull the items from the scene
|
||||||
auto shadowFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered();
|
auto shadowFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered();
|
||||||
|
@ -127,6 +129,8 @@ RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) {
|
||||||
|
|
||||||
// GPU jobs: Render to shadow map
|
// GPU jobs: Render to shadow map
|
||||||
addJob<RenderShadowMap>("RenderShadowMap", sortedShapes, shapePlumber);
|
addJob<RenderShadowMap>("RenderShadowMap", sortedShapes, shapePlumber);
|
||||||
|
|
||||||
|
addJob<RenderShadowTeardown>("Teardown", cachedMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderShadowTask::configure(const Config& configuration) {
|
void RenderShadowTask::configure(const Config& configuration) {
|
||||||
|
@ -144,16 +148,18 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto job : _jobs) {
|
||||||
|
job.run(sceneContext, renderContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) {
|
||||||
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
||||||
const auto globalShadow = lightStage->getShadow(0);
|
const auto globalShadow = lightStage->getShadow(0);
|
||||||
|
|
||||||
// If the global light is not set, bail
|
|
||||||
if (!globalShadow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache old render args
|
// Cache old render args
|
||||||
RenderArgs::RenderMode mode = args->_renderMode;
|
RenderArgs* args = renderContext->args;
|
||||||
|
output = args->_renderMode;
|
||||||
|
|
||||||
auto nearClip = args->getViewFrustum().getNearClip();
|
auto nearClip = args->getViewFrustum().getNearClip();
|
||||||
float nearDepth = -args->_boomOffset.z;
|
float nearDepth = -args->_boomOffset.z;
|
||||||
|
@ -163,14 +169,12 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render
|
||||||
// Set the keylight render args
|
// Set the keylight render args
|
||||||
args->pushViewFrustum(*(globalShadow->getFrustum()));
|
args->pushViewFrustum(*(globalShadow->getFrustum()));
|
||||||
args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;
|
args->_renderMode = RenderArgs::SHADOW_RENDER_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Allow runtime manipulation of culling ShouldRenderFunctor
|
void RenderShadowTeardown::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Input& input) {
|
||||||
|
RenderArgs* args = renderContext->args;
|
||||||
for (auto job : _jobs) {
|
|
||||||
job.run(sceneContext, renderContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the render args
|
// Reset the render args
|
||||||
args->popViewFrustum();
|
args->popViewFrustum();
|
||||||
args->_renderMode = mode;
|
args->_renderMode = input;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,4 +52,18 @@ public:
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RenderShadowSetup {
|
||||||
|
public:
|
||||||
|
using Output = RenderArgs::RenderMode;
|
||||||
|
using JobModel = render::Job::ModelO<RenderShadowSetup, Output>;
|
||||||
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output);
|
||||||
|
};
|
||||||
|
|
||||||
|
class RenderShadowTeardown {
|
||||||
|
public:
|
||||||
|
using Input = RenderArgs::RenderMode;
|
||||||
|
using JobModel = render::Job::ModelI<RenderShadowTeardown, Input>;
|
||||||
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Input& input);
|
||||||
|
};
|
||||||
|
|
||||||
#endif // hifi_RenderShadowTask_h
|
#endif // hifi_RenderShadowTask_h
|
||||||
|
|
Loading…
Reference in a new issue