This commit is contained in:
SamGondelman 2018-10-08 18:05:09 -07:00
parent de90ce5f2b
commit c10bb7d525
25 changed files with 66 additions and 61 deletions

View file

@ -64,8 +64,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
const auto& backgroundStage = renderContext->_scene->getStage<BackgroundStage>(); const auto& backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
const auto& backgroundFrame = inputs.get1(); const auto& backgroundFrame = inputs.get1();
graphics::SkyboxPointer skybox; graphics::SkyboxPointer skybox;
if (backgroundStage && backgroundFrame._backgrounds.size()) { if (backgroundStage && backgroundFrame->_backgrounds.size()) {
const auto& background = backgroundStage->getBackground(backgroundFrame._backgrounds.front()); const auto& background = backgroundStage->getBackground(backgroundFrame->_backgrounds.front());
if (background) { if (background) {
skybox = background->getSkybox(); skybox = background->getSkybox();
} }

View file

@ -65,6 +65,7 @@ public:
BackgroundStage::BackgroundIndices _backgrounds; BackgroundStage::BackgroundIndices _backgrounds;
}; };
using FramePointer = std::shared_ptr<Frame>;
Frame _currentFrame; Frame _currentFrame;
}; };
@ -80,7 +81,7 @@ public:
class DrawBackgroundStage { class DrawBackgroundStage {
public: public:
using Inputs = render::VaryingSet2<LightingModelPointer, BackgroundStage::Frame>; using Inputs = render::VaryingSet2<LightingModelPointer, BackgroundStage::FramePointer>;
using JobModel = render::Job::ModelI<DrawBackgroundStage, Inputs>; using JobModel = render::Job::ModelI<DrawBackgroundStage, Inputs>;
DrawBackgroundStage() {} DrawBackgroundStage() {}

View file

@ -38,8 +38,8 @@ void BloomThreshold::run(const render::RenderContextPointer& renderContext, cons
const auto bloomFrame = inputs.get2(); const auto bloomFrame = inputs.get2();
const auto& bloomStage = renderContext->_scene->getStage<BloomStage>(); const auto& bloomStage = renderContext->_scene->getStage<BloomStage>();
graphics::BloomPointer bloom; graphics::BloomPointer bloom;
if (bloomStage && bloomFrame._blooms.size()) { if (bloomStage && bloomFrame->_blooms.size()) {
bloom = bloomStage->getBloom(bloomFrame._blooms.front()); bloom = bloomStage->getBloom(bloomFrame->_blooms.front());
} }
if (!bloom) { if (!bloom) {
renderContext->taskFlow.abortTask(); renderContext->taskFlow.abortTask();

View file

@ -28,7 +28,7 @@ class BloomThresholdConfig : public render::Job::Config {
class BloomThreshold { class BloomThreshold {
public: public:
using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::Frame>; using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::FramePointer>;
using Outputs = render::VaryingSet3<gpu::FramebufferPointer, float, graphics::BloomPointer>; using Outputs = render::VaryingSet3<gpu::FramebufferPointer, float, graphics::BloomPointer>;
using Config = BloomThresholdConfig; using Config = BloomThresholdConfig;
using JobModel = render::Job::ModelIO<BloomThreshold, Inputs, Outputs, Config>; using JobModel = render::Job::ModelIO<BloomThreshold, Inputs, Outputs, Config>;
@ -127,7 +127,7 @@ private:
class BloomEffect { class BloomEffect {
public: public:
using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::Frame>; using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::FramePointer>;
using Config = BloomConfig; using Config = BloomConfig;
using JobModel = render::Task::ModelI<BloomEffect, Inputs, Config>; using JobModel = render::Task::ModelI<BloomEffect, Inputs, Config>;

View file

@ -65,6 +65,7 @@ public:
BloomStage::BloomIndices _blooms; BloomStage::BloomIndices _blooms;
}; };
using FramePointer = std::shared_ptr<Frame>;
Frame _currentFrame; Frame _currentFrame;
}; };

View file

@ -444,7 +444,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage); assert(lightStage);
assert(lightStage->getNumLights() > 0); assert(lightStage->getNumLights() > 0);
auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(lightFrame); auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(*lightFrame);
const auto& globalShadow = lightAndShadow.second; const auto& globalShadow = lightAndShadow.second;
if (globalShadow) { if (globalShadow) {
batch.setResourceTexture(Textures::Shadow, globalShadow->map); batch.setResourceTexture(Textures::Shadow, globalShadow->map);

View file

@ -47,7 +47,7 @@ public:
AmbientOcclusionFramebufferPointer, AmbientOcclusionFramebufferPointer,
VelocityFramebufferPointer, VelocityFramebufferPointer,
DeferredFrameTransformPointer, DeferredFrameTransformPointer,
LightStage::Frame>; LightStage::FramePointer>;
using Config = DebugDeferredBufferConfig; using Config = DebugDeferredBufferConfig;
using JobModel = render::Job::ModelI<DebugDeferredBuffer, Inputs, Config>; using JobModel = render::Job::ModelI<DebugDeferredBuffer, Inputs, Config>;

View file

@ -373,8 +373,8 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
const DeferredFrameTransformPointer& frameTransform, const DeferredFrameTransformPointer& frameTransform,
const DeferredFramebufferPointer& deferredFramebuffer, const DeferredFramebufferPointer& deferredFramebuffer,
const LightingModelPointer& lightingModel, const LightingModelPointer& lightingModel,
const LightStage::Frame& lightFrame, const LightStage::FramePointer& lightFrame,
const HazeStage::Frame& hazeFrame, const HazeStage::FramePointer& hazeFrame,
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource, const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource,
@ -434,7 +434,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage); assert(lightStage);
assert(lightStage->getNumLights() > 0); assert(lightStage->getNumLights() > 0);
auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(lightFrame); auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(*lightFrame);
const auto& globalShadow = lightAndShadow.second; const auto& globalShadow = lightAndShadow.second;
// Bind the shadow buffers // Bind the shadow buffers
@ -448,8 +448,8 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
auto keyLight = lightAndShadow.first; auto keyLight = lightAndShadow.first;
graphics::LightPointer ambientLight; graphics::LightPointer ambientLight;
if (lightStage && lightFrame._ambientLights.size()) { if (lightStage && lightFrame->_ambientLights.size()) {
ambientLight = lightStage->getLight(lightFrame._ambientLights.front()); ambientLight = lightStage->getLight(lightFrame->_ambientLights.front());
} }
bool hasAmbientMap = (ambientLight != nullptr); bool hasAmbientMap = (ambientLight != nullptr);
@ -458,8 +458,8 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
// Check if keylight casts shadows // Check if keylight casts shadows
bool keyLightCastShadows { false }; bool keyLightCastShadows { false };
if (renderShadows && lightStage && lightFrame._sunLights.size()) { if (renderShadows && lightStage && lightFrame->_sunLights.size()) {
graphics::LightPointer keyLight = lightStage->getLight(lightFrame._sunLights.front()); graphics::LightPointer keyLight = lightStage->getLight(lightFrame->_sunLights.front());
if (keyLight) { if (keyLight) {
keyLightCastShadows = keyLight->getCastShadows(); keyLightCastShadows = keyLight->getCastShadows();
} }
@ -496,12 +496,12 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
} }
// Setup the global lighting // Setup the global lighting
deferredLightingEffect->setupKeyLightBatch(args, batch, lightFrame); deferredLightingEffect->setupKeyLightBatch(args, batch, *lightFrame);
// Haze // Haze
const auto& hazeStage = args->_scene->getStage<HazeStage>(); const auto& hazeStage = args->_scene->getStage<HazeStage>();
if (hazeStage && hazeFrame._hazes.size() > 0) { if (hazeStage && hazeFrame->_hazes.size() > 0) {
const auto& hazePointer = hazeStage->getHaze(hazeFrame._hazes.front()); const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front());
if (hazePointer) { if (hazePointer) {
batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
} }

View file

@ -145,8 +145,8 @@ public:
const DeferredFrameTransformPointer& frameTransform, const DeferredFrameTransformPointer& frameTransform,
const DeferredFramebufferPointer& deferredFramebuffer, const DeferredFramebufferPointer& deferredFramebuffer,
const LightingModelPointer& lightingModel, const LightingModelPointer& lightingModel,
const LightStage::Frame& lightFrame, const LightStage::FramePointer& lightFrame,
const HazeStage::Frame& hazeFrame, const HazeStage::FramePointer& hazeFrame,
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource, const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource,
@ -184,7 +184,7 @@ class RenderDeferred {
public: public:
using Inputs = render::VaryingSet9< using Inputs = render::VaryingSet9<
DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer, DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer,
AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, LightStage::Frame, HazeStage::Frame>; AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, LightStage::FramePointer, HazeStage::FramePointer>;
using Config = RenderDeferredConfig; using Config = RenderDeferredConfig;
using JobModel = render::Job::ModelI<RenderDeferred, Inputs, Config>; using JobModel = render::Job::ModelI<RenderDeferred, Inputs, Config>;

View file

@ -35,8 +35,8 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
const auto hazeFrame = inputs.get0(); const auto hazeFrame = inputs.get0();
const auto& hazeStage = renderContext->args->_scene->getStage<HazeStage>(); const auto& hazeStage = renderContext->args->_scene->getStage<HazeStage>();
graphics::HazePointer haze; graphics::HazePointer haze;
if (hazeStage && hazeFrame._hazes.size() > 0) { if (hazeStage && hazeFrame->_hazes.size() > 0) {
haze = hazeStage->getHaze(hazeFrame._hazes.front()); haze = hazeStage->getHaze(hazeFrame->_hazes.front());
} }
if (!haze) { if (!haze) {
@ -86,7 +86,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
auto lightStage = args->_scene->getStage<LightStage>(); auto lightStage = args->_scene->getStage<LightStage>();
if (lightStage) { if (lightStage) {
graphics::LightPointer keyLight; graphics::LightPointer keyLight;
keyLight = lightStage->getCurrentKeyLight(lightFrame); keyLight = lightStage->getCurrentKeyLight(*lightFrame);
if (keyLight) { if (keyLight) {
batch.setUniformBuffer(gr::Buffer::KeyLight, keyLight->getLightSchemaBuffer()); batch.setUniformBuffer(gr::Buffer::KeyLight, keyLight->getLightSchemaBuffer());
} }

View file

@ -30,7 +30,7 @@ using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
class DrawHaze { class DrawHaze {
public: public:
using Inputs = render::VaryingSet6<HazeStage::Frame, gpu::FramebufferPointer, LinearDepthFramebufferPointer, DeferredFrameTransformPointer, LightingModelPointer, LightStage::Frame>; using Inputs = render::VaryingSet6<HazeStage::FramePointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, DeferredFrameTransformPointer, LightingModelPointer, LightStage::FramePointer>;
using JobModel = render::Job::ModelI<DrawHaze, Inputs>; using JobModel = render::Job::ModelI<DrawHaze, Inputs>;
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);

View file

@ -65,6 +65,7 @@ public:
HazeStage::HazeIndices _hazes; HazeStage::HazeIndices _hazes;
}; };
using FramePointer = std::shared_ptr<Frame>;
Frame _currentFrame; Frame _currentFrame;
}; };

View file

@ -175,15 +175,15 @@ void LightClusters::updateLightStage(const LightStagePointer& lightStage) {
} }
void LightClusters::updateLightFrame(const LightStage::Frame& lightFrame, bool points, bool spots) { void LightClusters::updateLightFrame(const LightStage::FramePointer& lightFrame, bool points, bool spots) {
// start fresh // start fresh
_visibleLightIndices.clear(); _visibleLightIndices.clear();
// Now gather the lights // Now gather the lights
// gather lights // gather lights
auto& srcPointLights = lightFrame._pointLights; auto& srcPointLights = lightFrame->_pointLights;
auto& srcSpotLights = lightFrame._spotLights; auto& srcSpotLights = lightFrame->_spotLights;
int numPointLights = (int)srcPointLights.size(); int numPointLights = (int)srcPointLights.size();
int numSpotLights = (int)srcSpotLights.size(); int numSpotLights = (int)srcSpotLights.size();

View file

@ -79,7 +79,7 @@ public:
void updateLightStage(const LightStagePointer& lightStage); void updateLightStage(const LightStagePointer& lightStage);
void updateLightFrame(const LightStage::Frame& lightFrame, bool points = true, bool spots = true); void updateLightFrame(const LightStage::FramePointer& lightFrame, bool points = true, bool spots = true);
glm::ivec3 updateClusters(); glm::ivec3 updateClusters();
@ -167,7 +167,7 @@ protected:
class LightClusteringPass { class LightClusteringPass {
public: public:
using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, LightingModelPointer, LightStage::Frame, LinearDepthFramebufferPointer>; using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, LightingModelPointer, LightStage::FramePointer, LinearDepthFramebufferPointer>;
using Outputs = LightClustersPointer; using Outputs = LightClustersPointer;
using Config = LightClusteringPassConfig; using Config = LightClusteringPassConfig;
using JobModel = render::Job::ModelIO<LightClusteringPass, Inputs, Outputs, Config>; using JobModel = render::Job::ModelIO<LightClusteringPass, Inputs, Outputs, Config>;

View file

@ -180,6 +180,7 @@ public:
LightStage::LightIndices _sunLights; LightStage::LightIndices _sunLights;
LightStage::LightIndices _ambientLights; LightStage::LightIndices _ambientLights;
}; };
using FramePointer = std::shared_ptr<Frame>;
Frame _currentFrame; Frame _currentFrame;

View file

@ -218,7 +218,7 @@ void ExtractFrustums::run(const render::RenderContextPointer& renderContext, con
for (auto i = 0; i < SHADOW_CASCADE_FRUSTUM_COUNT; i++) { for (auto i = 0; i < SHADOW_CASCADE_FRUSTUM_COUNT; i++) {
auto& shadowFrustum = output[SHADOW_CASCADE0_FRUSTUM+i].edit<ViewFrustumPointer>(); auto& shadowFrustum = output[SHADOW_CASCADE0_FRUSTUM+i].edit<ViewFrustumPointer>();
if (lightStage) { if (lightStage) {
auto globalShadow = lightStage->getCurrentKeyShadow(lightFrame); auto globalShadow = lightStage->getCurrentKeyShadow(*lightFrame);
if (globalShadow && i<(int)globalShadow->getCascadeCount()) { if (globalShadow && i<(int)globalShadow->getCascadeCount()) {
auto& cascade = globalShadow->getCascade(i); auto& cascade = globalShadow->getCascade(i);
@ -235,17 +235,17 @@ void ExtractFrustums::run(const render::RenderContextPointer& renderContext, con
void FetchCurrentFrames::run(const render::RenderContextPointer& renderContext, Outputs& outputs) { void FetchCurrentFrames::run(const render::RenderContextPointer& renderContext, Outputs& outputs) {
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage); assert(lightStage);
outputs.edit0() = lightStage->_currentFrame; outputs.edit0() = std::make_shared<LightStage::Frame>(lightStage->_currentFrame);
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>(); auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
assert(backgroundStage); assert(backgroundStage);
outputs.edit1() = backgroundStage->_currentFrame; outputs.edit1() = std::make_shared<BackgroundStage::Frame>(backgroundStage->_currentFrame);
auto hazeStage = renderContext->_scene->getStage<HazeStage>(); auto hazeStage = renderContext->_scene->getStage<HazeStage>();
assert(hazeStage); assert(hazeStage);
outputs.edit2() = hazeStage->_currentFrame; outputs.edit2() = std::make_shared<HazeStage::Frame>(hazeStage->_currentFrame);
auto bloomStage = renderContext->_scene->getStage<BloomStage>(); auto bloomStage = renderContext->_scene->getStage<BloomStage>();
assert(bloomStage); assert(bloomStage);
outputs.edit3() = bloomStage->_currentFrame; outputs.edit3() = std::make_shared<BloomStage::Frame>(bloomStage->_currentFrame);
} }

View file

@ -111,7 +111,7 @@ public:
FRUSTUM_COUNT FRUSTUM_COUNT
}; };
using Inputs = LightStage::Frame; using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingArray<ViewFrustumPointer, FRUSTUM_COUNT>; using Outputs = render::VaryingArray<ViewFrustumPointer, FRUSTUM_COUNT>;
using JobModel = render::Job::ModelIO<ExtractFrustums, Inputs, Outputs>; using JobModel = render::Job::ModelIO<ExtractFrustums, Inputs, Outputs>;
@ -121,7 +121,7 @@ public:
class FetchCurrentFrames { class FetchCurrentFrames {
public: public:
using Outputs = render::VaryingSet4<LightStage::Frame, BackgroundStage::Frame, HazeStage::Frame, BloomStage::Frame>; using Outputs = render::VaryingSet4<LightStage::FramePointer, BackgroundStage::FramePointer, HazeStage::FramePointer, BloomStage::FramePointer>;
using JobModel = render::Job::ModelO<FetchCurrentFrames, Outputs>; using JobModel = render::Job::ModelO<FetchCurrentFrames, Outputs>;
FetchCurrentFrames() {} FetchCurrentFrames() {}

View file

@ -383,13 +383,13 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer());
// Set the light // Set the light
deferredLightingEffect->setupKeyLightBatch(args, batch, lightFrame); deferredLightingEffect->setupKeyLightBatch(args, batch, *lightFrame);
deferredLightingEffect->setupLocalLightsBatch(batch, lightClusters); deferredLightingEffect->setupLocalLightsBatch(batch, lightClusters);
// Setup haze if current zone has haze // Setup haze if current zone has haze
const auto& hazeStage = args->_scene->getStage<HazeStage>(); const auto& hazeStage = args->_scene->getStage<HazeStage>();
if (hazeStage && hazeFrame._hazes.size() > 0) { if (hazeStage && hazeFrame->_hazes.size() > 0) {
const auto& hazePointer = hazeStage->getHaze(hazeFrame._hazes.front()); const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front());
if (hazePointer) { if (hazePointer) {
batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
} }

View file

@ -43,7 +43,7 @@ protected:
class DrawDeferred { class DrawDeferred {
public: public:
using Inputs = render::VaryingSet6<render::ItemBounds, HazeStage::Frame, LightStage::Frame, LightingModelPointer, LightClustersPointer, glm::vec2>; using Inputs = render::VaryingSet6<render::ItemBounds, HazeStage::FramePointer, LightStage::FramePointer, LightingModelPointer, LightClustersPointer, glm::vec2>;
using Config = DrawDeferredConfig; using Config = DrawDeferredConfig;
using JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>; using JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>;

View file

@ -187,12 +187,12 @@ void PrepareForward::run(const RenderContextPointer& renderContext, const Inputs
graphics::LightPointer keySunLight; graphics::LightPointer keySunLight;
auto lightStage = args->_scene->getStage<LightStage>(); auto lightStage = args->_scene->getStage<LightStage>();
if (lightStage) { if (lightStage) {
keySunLight = lightStage->getCurrentKeyLight(inputs); keySunLight = lightStage->getCurrentKeyLight(*inputs);
} }
graphics::LightPointer keyAmbiLight; graphics::LightPointer keyAmbiLight;
if (lightStage) { if (lightStage) {
keyAmbiLight = lightStage->getCurrentAmbientLight(inputs); keyAmbiLight = lightStage->getCurrentAmbientLight(*inputs);
} }
if (keySunLight) { if (keySunLight) {

View file

@ -41,7 +41,7 @@ private:
class PrepareForward { class PrepareForward {
public: public:
using Inputs = LightStage::Frame; using Inputs = LightStage::FramePointer;
using JobModel = render::Job::ModelI<PrepareForward, Inputs>; using JobModel = render::Job::ModelI<PrepareForward, Inputs>;
void run(const render::RenderContextPointer& renderContext, void run(const render::RenderContextPointer& renderContext,

View file

@ -213,7 +213,7 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage); assert(lightStage);
auto shadow = lightStage->getCurrentKeyShadow(lightFrame); auto shadow = lightStage->getCurrentKeyShadow(*lightFrame);
if (!shadow || _cascadeIndex >= shadow->getCascadeCount()) { if (!shadow || _cascadeIndex >= shadow->getCascadeCount()) {
return; return;
} }
@ -336,8 +336,9 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) {
void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) { void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) {
// Abort all jobs if not casting shadows // Abort all jobs if not casting shadows
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
auto lightFrame = *input;
assert(lightStage); assert(lightStage);
if (!lightStage->getCurrentKeyLight(input) || !lightStage->getCurrentKeyLight(input)->getCastShadows()) { if (!lightStage->getCurrentKeyLight(lightFrame) || !lightStage->getCurrentKeyLight(lightFrame)->getCastShadows()) {
renderContext->taskFlow.abortTask(); renderContext->taskFlow.abortTask();
return; return;
} }
@ -351,7 +352,7 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
*_cameraFrustum = args->getViewFrustum(); *_cameraFrustum = args->getViewFrustum();
output.edit2() = _cameraFrustum; output.edit2() = _cameraFrustum;
const auto globalShadow = lightStage->getCurrentKeyShadow(input); const auto globalShadow = lightStage->getCurrentKeyShadow(lightFrame);
if (globalShadow) { if (globalShadow) {
globalShadow->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); globalShadow->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);
@ -420,7 +421,7 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) { void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) {
auto lightStage = renderContext->_scene->getStage<LightStage>(); auto lightStage = renderContext->_scene->getStage<LightStage>();
const auto& lightFrame = input; const auto& lightFrame = *input;
assert(lightStage); assert(lightStage);
// Cache old render args // Cache old render args
@ -507,7 +508,7 @@ void CullShadowBounds::run(const render::RenderContextPointer& renderContext, co
outShapes.clear(); outShapes.clear();
outBounds = AABox(); outBounds = AABox();
const auto& lightFrame = inputs.get3(); const auto& lightFrame = *inputs.get3();
auto cullFunctor = inputs.get4(); auto cullFunctor = inputs.get4();
render::CullFunctor shadowCullFunctor = [cullFunctor](const RenderArgs* args, const AABox& bounds) { render::CullFunctor shadowCullFunctor = [cullFunctor](const RenderArgs* args, const AABox& bounds) {

View file

@ -25,7 +25,7 @@ class ViewFrustum;
class RenderShadowMap { class RenderShadowMap {
public: public:
using Inputs = render::VaryingSet3<render::ShapeBounds, AABox, LightStage::Frame>; using Inputs = render::VaryingSet3<render::ShapeBounds, AABox, LightStage::FramePointer>;
using JobModel = render::Job::ModelI<RenderShadowMap, Inputs>; using JobModel = render::Job::ModelI<RenderShadowMap, Inputs>;
RenderShadowMap(render::ShapePlumberPointer shapePlumber, unsigned int cascadeIndex) : _shapePlumber{ shapePlumber }, _cascadeIndex{ cascadeIndex } {} RenderShadowMap(render::ShapePlumberPointer shapePlumber, unsigned int cascadeIndex) : _shapePlumber{ shapePlumber }, _cascadeIndex{ cascadeIndex } {}
@ -100,7 +100,7 @@ signals:
class RenderShadowSetup { class RenderShadowSetup {
public: public:
using Inputs = LightStage::Frame; using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingSet3<RenderArgs::RenderMode, glm::ivec2, ViewFrustumPointer>; using Outputs = render::VaryingSet3<RenderArgs::RenderMode, glm::ivec2, ViewFrustumPointer>;
using Config = RenderShadowSetupConfig; using Config = RenderShadowSetupConfig;
using JobModel = render::Job::ModelIO<RenderShadowSetup, Inputs, Outputs, Config>; using JobModel = render::Job::ModelIO<RenderShadowSetup, Inputs, Outputs, Config>;
@ -124,7 +124,7 @@ private:
class RenderShadowCascadeSetup { class RenderShadowCascadeSetup {
public: public:
using Inputs = LightStage::Frame; using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingSet3<render::ItemFilter, ViewFrustumPointer, RenderShadowTask::CullFunctor>; using Outputs = render::VaryingSet3<render::ItemFilter, ViewFrustumPointer, RenderShadowTask::CullFunctor>;
using JobModel = render::Job::ModelIO<RenderShadowCascadeSetup, Inputs, Outputs>; using JobModel = render::Job::ModelIO<RenderShadowCascadeSetup, Inputs, Outputs>;
@ -155,7 +155,7 @@ public:
class CullShadowBounds { class CullShadowBounds {
public: public:
using Inputs = render::VaryingSet5<render::ShapeBounds, render::ItemFilter, ViewFrustumPointer, LightStage::Frame, RenderShadowTask::CullFunctor>; using Inputs = render::VaryingSet5<render::ShapeBounds, render::ItemFilter, ViewFrustumPointer, LightStage::FramePointer, RenderShadowTask::CullFunctor>;
using Outputs = render::VaryingSet2<render::ShapeBounds, AABox>; using Outputs = render::VaryingSet2<render::ShapeBounds, AABox>;
using JobModel = render::Job::ModelIO<CullShadowBounds, Inputs, Outputs>; using JobModel = render::Job::ModelIO<CullShadowBounds, Inputs, Outputs>;

View file

@ -124,23 +124,23 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
auto lightStage = context->_scene->getStage<LightStage>(LightStage::getName()); auto lightStage = context->_scene->getStage<LightStage>(LightStage::getName());
std::vector<graphics::LightPointer> keyLightStack; std::vector<graphics::LightPointer> keyLightStack;
if (lightStage && lightFrame._sunLights.size()) { if (lightStage && lightFrame->_sunLights.size()) {
for (auto index : lightFrame._sunLights) { for (auto index : lightFrame->_sunLights) {
keyLightStack.push_back(lightStage->getLight(index)); keyLightStack.push_back(lightStage->getLight(index));
} }
} }
std::vector<graphics::LightPointer> ambientLightStack; std::vector<graphics::LightPointer> ambientLightStack;
if (lightStage && lightFrame._ambientLights.size()) { if (lightStage && lightFrame->_ambientLights.size()) {
for (auto index : lightFrame._ambientLights) { for (auto index : lightFrame->_ambientLights) {
ambientLightStack.push_back(lightStage->getLight(index)); ambientLightStack.push_back(lightStage->getLight(index));
} }
} }
auto backgroundStage = context->_scene->getStage<BackgroundStage>(BackgroundStage::getName()); auto backgroundStage = context->_scene->getStage<BackgroundStage>(BackgroundStage::getName());
std::vector<graphics::SkyboxPointer> skyboxStack; std::vector<graphics::SkyboxPointer> skyboxStack;
if (backgroundStage && backgroundFrame._backgrounds.size()) { if (backgroundStage && backgroundFrame->_backgrounds.size()) {
for (auto index : backgroundFrame._backgrounds) { for (auto index : backgroundFrame->_backgrounds) {
auto background = backgroundStage->getBackground(index); auto background = backgroundStage->getBackground(index);
if (background) { if (background) {
skyboxStack.push_back(background->getSkybox()); skyboxStack.push_back(background->getSkybox());

View file

@ -72,7 +72,7 @@ public:
Config(bool enabled = false) : JobConfig(enabled) {} Config(bool enabled = false) : JobConfig(enabled) {}
}; };
using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, LightStage::Frame, BackgroundStage::Frame>; using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, LightStage::FramePointer, BackgroundStage::FramePointer>;
using JobModel = render::Job::ModelI<DebugZoneLighting, Inputs, Config>; using JobModel = render::Job::ModelI<DebugZoneLighting, Inputs, Config>;
DebugZoneLighting() {} DebugZoneLighting() {}