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& backgroundFrame = inputs.get1();
graphics::SkyboxPointer skybox;
if (backgroundStage && backgroundFrame._backgrounds.size()) {
const auto& background = backgroundStage->getBackground(backgroundFrame._backgrounds.front());
if (backgroundStage && backgroundFrame->_backgrounds.size()) {
const auto& background = backgroundStage->getBackground(backgroundFrame->_backgrounds.front());
if (background) {
skybox = background->getSkybox();
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -145,8 +145,8 @@ public:
const DeferredFrameTransformPointer& frameTransform,
const DeferredFramebufferPointer& deferredFramebuffer,
const LightingModelPointer& lightingModel,
const LightStage::Frame& lightFrame,
const HazeStage::Frame& hazeFrame,
const LightStage::FramePointer& lightFrame,
const HazeStage::FramePointer& hazeFrame,
const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer,
const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer,
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource,
@ -184,7 +184,7 @@ class RenderDeferred {
public:
using Inputs = render::VaryingSet9<
DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer,
AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, LightStage::Frame, HazeStage::Frame>;
AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, LightStage::FramePointer, HazeStage::FramePointer>;
using Config = RenderDeferredConfig;
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& hazeStage = renderContext->args->_scene->getStage<HazeStage>();
graphics::HazePointer haze;
if (hazeStage && hazeFrame._hazes.size() > 0) {
haze = hazeStage->getHaze(hazeFrame._hazes.front());
if (hazeStage && hazeFrame->_hazes.size() > 0) {
haze = hazeStage->getHaze(hazeFrame->_hazes.front());
}
if (!haze) {
@ -86,7 +86,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
auto lightStage = args->_scene->getStage<LightStage>();
if (lightStage) {
graphics::LightPointer keyLight;
keyLight = lightStage->getCurrentKeyLight(lightFrame);
keyLight = lightStage->getCurrentKeyLight(*lightFrame);
if (keyLight) {
batch.setUniformBuffer(gr::Buffer::KeyLight, keyLight->getLightSchemaBuffer());
}

View file

@ -30,7 +30,7 @@ using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
class DrawHaze {
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>;
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);

View file

@ -65,6 +65,7 @@ public:
HazeStage::HazeIndices _hazes;
};
using FramePointer = std::shared_ptr<Frame>;
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
_visibleLightIndices.clear();
// Now gather the lights
// gather lights
auto& srcPointLights = lightFrame._pointLights;
auto& srcSpotLights = lightFrame._spotLights;
auto& srcPointLights = lightFrame->_pointLights;
auto& srcSpotLights = lightFrame->_spotLights;
int numPointLights = (int)srcPointLights.size();
int numSpotLights = (int)srcSpotLights.size();

View file

@ -79,7 +79,7 @@ public:
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();
@ -167,7 +167,7 @@ protected:
class LightClusteringPass {
public:
using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, LightingModelPointer, LightStage::Frame, LinearDepthFramebufferPointer>;
using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, LightingModelPointer, LightStage::FramePointer, LinearDepthFramebufferPointer>;
using Outputs = LightClustersPointer;
using Config = LightClusteringPassConfig;
using JobModel = render::Job::ModelIO<LightClusteringPass, Inputs, Outputs, Config>;

View file

@ -180,6 +180,7 @@ public:
LightStage::LightIndices _sunLights;
LightStage::LightIndices _ambientLights;
};
using FramePointer = std::shared_ptr<Frame>;
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++) {
auto& shadowFrustum = output[SHADOW_CASCADE0_FRUSTUM+i].edit<ViewFrustumPointer>();
if (lightStage) {
auto globalShadow = lightStage->getCurrentKeyShadow(lightFrame);
auto globalShadow = lightStage->getCurrentKeyShadow(*lightFrame);
if (globalShadow && i<(int)globalShadow->getCascadeCount()) {
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) {
auto lightStage = renderContext->_scene->getStage<LightStage>();
assert(lightStage);
outputs.edit0() = lightStage->_currentFrame;
outputs.edit0() = std::make_shared<LightStage::Frame>(lightStage->_currentFrame);
auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>();
assert(backgroundStage);
outputs.edit1() = backgroundStage->_currentFrame;
outputs.edit1() = std::make_shared<BackgroundStage::Frame>(backgroundStage->_currentFrame);
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
assert(hazeStage);
outputs.edit2() = hazeStage->_currentFrame;
outputs.edit2() = std::make_shared<HazeStage::Frame>(hazeStage->_currentFrame);
auto bloomStage = renderContext->_scene->getStage<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
};
using Inputs = LightStage::Frame;
using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingArray<ViewFrustumPointer, FRUSTUM_COUNT>;
using JobModel = render::Job::ModelIO<ExtractFrustums, Inputs, Outputs>;
@ -121,7 +121,7 @@ public:
class FetchCurrentFrames {
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>;
FetchCurrentFrames() {}

View file

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

View file

@ -43,7 +43,7 @@ protected:
class DrawDeferred {
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 JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>;

View file

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

View file

@ -41,7 +41,7 @@ private:
class PrepareForward {
public:
using Inputs = LightStage::Frame;
using Inputs = LightStage::FramePointer;
using JobModel = render::Job::ModelI<PrepareForward, Inputs>;
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>();
assert(lightStage);
auto shadow = lightStage->getCurrentKeyShadow(lightFrame);
auto shadow = lightStage->getCurrentKeyShadow(*lightFrame);
if (!shadow || _cascadeIndex >= shadow->getCascadeCount()) {
return;
}
@ -336,8 +336,9 @@ void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) {
void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Inputs& input, Outputs& output) {
// Abort all jobs if not casting shadows
auto lightStage = renderContext->_scene->getStage<LightStage>();
auto lightFrame = *input;
assert(lightStage);
if (!lightStage->getCurrentKeyLight(input) || !lightStage->getCurrentKeyLight(input)->getCastShadows()) {
if (!lightStage->getCurrentKeyLight(lightFrame) || !lightStage->getCurrentKeyLight(lightFrame)->getCastShadows()) {
renderContext->taskFlow.abortTask();
return;
}
@ -351,7 +352,7 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
*_cameraFrustum = args->getViewFrustum();
output.edit2() = _cameraFrustum;
const auto globalShadow = lightStage->getCurrentKeyShadow(input);
const auto globalShadow = lightStage->getCurrentKeyShadow(lightFrame);
if (globalShadow) {
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) {
auto lightStage = renderContext->_scene->getStage<LightStage>();
const auto& lightFrame = input;
const auto& lightFrame = *input;
assert(lightStage);
// Cache old render args
@ -507,7 +508,7 @@ void CullShadowBounds::run(const render::RenderContextPointer& renderContext, co
outShapes.clear();
outBounds = AABox();
const auto& lightFrame = inputs.get3();
const auto& lightFrame = *inputs.get3();
auto cullFunctor = inputs.get4();
render::CullFunctor shadowCullFunctor = [cullFunctor](const RenderArgs* args, const AABox& bounds) {

View file

@ -25,7 +25,7 @@ class ViewFrustum;
class RenderShadowMap {
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>;
RenderShadowMap(render::ShapePlumberPointer shapePlumber, unsigned int cascadeIndex) : _shapePlumber{ shapePlumber }, _cascadeIndex{ cascadeIndex } {}
@ -100,7 +100,7 @@ signals:
class RenderShadowSetup {
public:
using Inputs = LightStage::Frame;
using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingSet3<RenderArgs::RenderMode, glm::ivec2, ViewFrustumPointer>;
using Config = RenderShadowSetupConfig;
using JobModel = render::Job::ModelIO<RenderShadowSetup, Inputs, Outputs, Config>;
@ -124,7 +124,7 @@ private:
class RenderShadowCascadeSetup {
public:
using Inputs = LightStage::Frame;
using Inputs = LightStage::FramePointer;
using Outputs = render::VaryingSet3<render::ItemFilter, ViewFrustumPointer, RenderShadowTask::CullFunctor>;
using JobModel = render::Job::ModelIO<RenderShadowCascadeSetup, Inputs, Outputs>;
@ -155,7 +155,7 @@ public:
class CullShadowBounds {
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 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());
std::vector<graphics::LightPointer> keyLightStack;
if (lightStage && lightFrame._sunLights.size()) {
for (auto index : lightFrame._sunLights) {
if (lightStage && lightFrame->_sunLights.size()) {
for (auto index : lightFrame->_sunLights) {
keyLightStack.push_back(lightStage->getLight(index));
}
}
std::vector<graphics::LightPointer> ambientLightStack;
if (lightStage && lightFrame._ambientLights.size()) {
for (auto index : lightFrame._ambientLights) {
if (lightStage && lightFrame->_ambientLights.size()) {
for (auto index : lightFrame->_ambientLights) {
ambientLightStack.push_back(lightStage->getLight(index));
}
}
auto backgroundStage = context->_scene->getStage<BackgroundStage>(BackgroundStage::getName());
std::vector<graphics::SkyboxPointer> skyboxStack;
if (backgroundStage && backgroundFrame._backgrounds.size()) {
for (auto index : backgroundFrame._backgrounds) {
if (backgroundStage && backgroundFrame->_backgrounds.size()) {
for (auto index : backgroundFrame->_backgrounds) {
auto background = backgroundStage->getBackground(index);
if (background) {
skyboxStack.push_back(background->getSkybox());

View file

@ -72,7 +72,7 @@ public:
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>;
DebugZoneLighting() {}