mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-17 14:58:25 +02:00
Separating the state view dependant from the shadow to be able to have several versions in flight
This commit is contained in:
parent
94ae345daf
commit
8bfca612e3
4 changed files with 48 additions and 14 deletions
|
@ -93,10 +93,15 @@ public:
|
|||
const graphics::LightPointer& getLight() const { return _light; }
|
||||
|
||||
gpu::TexturePointer map;
|
||||
#include "Shadows_shared.slh"
|
||||
class Schema : public ShadowParameters {
|
||||
public:
|
||||
|
||||
Schema();
|
||||
|
||||
};
|
||||
protected:
|
||||
|
||||
#include "Shadows_shared.slh"
|
||||
|
||||
using Cascades = std::vector<Cascade>;
|
||||
|
||||
|
@ -106,12 +111,7 @@ public:
|
|||
float _maxDistance;
|
||||
Cascades _cascades;
|
||||
|
||||
class Schema : public ShadowParameters {
|
||||
public:
|
||||
|
||||
Schema();
|
||||
|
||||
};
|
||||
UniformBufferView _schemaBuffer = nullptr;
|
||||
};
|
||||
|
||||
|
@ -182,6 +182,24 @@ public:
|
|||
};
|
||||
using FramePointer = std::shared_ptr<Frame>;
|
||||
|
||||
class ShadowFrame {
|
||||
public:
|
||||
ShadowFrame() {}
|
||||
|
||||
void clear() {}
|
||||
|
||||
using Object = std::pair<gpu::BufferPointer, gpu::TexturePointer>;
|
||||
using Objects = std::vector<Object>;
|
||||
|
||||
void pushShadow(LightStage::Index index, const gpu::BufferPointer& params, const gpu::TexturePointer& maps) {
|
||||
_objects.emplace_back(params, maps);
|
||||
}
|
||||
|
||||
|
||||
Objects _objects;
|
||||
};
|
||||
using ShadowFramePointer = std::shared_ptr<ShadowFrame>;
|
||||
|
||||
Frame _currentFrame;
|
||||
|
||||
Index getAmbientOffLight() { return _ambientOffLightId; }
|
||||
|
|
|
@ -256,7 +256,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
|
||||
// Debugging task is happening in the "over" layer after tone mapping and just before HUD
|
||||
{ // Debug the bounds of the rendered items, still look at the zbuffer
|
||||
const auto debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, inputs[2], lightingStageInputs, lightClusters, linearDepthTarget, prepareDeferredOutputs, deferredFrameTransform, jitter, lightingModel).asVarying();
|
||||
const auto debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, inputs.get2(), lightingStageInputs, lightClusters, linearDepthTarget, prepareDeferredOutputs, deferredFrameTransform, jitter, lightingModel).asVarying();
|
||||
task.addJob<RenderDeferredTaskDebug>("DebugRenderDeferredTask", debugInputs);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
|
|||
#endif
|
||||
};
|
||||
|
||||
Output cascadeSceneBBoxes;
|
||||
render::VaryingArray<AABox,4> cascadeSceneBBoxes;
|
||||
|
||||
for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) {
|
||||
char jobName[64];
|
||||
|
@ -118,10 +118,11 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende
|
|||
|
||||
cascadeSceneBBoxes[i] = culledShadowItemsAndBounds.getN<CullShadowBounds::Outputs>(1);
|
||||
}
|
||||
|
||||
output = render::Varying(cascadeSceneBBoxes);
|
||||
|
||||
task.addJob<RenderShadowTeardown>("ShadowTeardown", setupOutput);
|
||||
|
||||
|
||||
output = Output(cascadeSceneBBoxes, setupOutput.getN<RenderShadowSetup::Outputs>(3));
|
||||
|
||||
}
|
||||
|
||||
static void computeNearFar(const Triangle& triangle, const Plane shadowClipPlanes[4], float& near, float& far) {
|
||||
|
@ -315,7 +316,7 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
|
|||
RenderShadowSetup::RenderShadowSetup() :
|
||||
_cameraFrustum{ std::make_shared<ViewFrustum>() },
|
||||
_coarseShadowFrustum{ std::make_shared<ViewFrustum>() } {
|
||||
|
||||
_shadowFrameCache = std::make_shared<LightStage::ShadowFrame>();
|
||||
}
|
||||
|
||||
void RenderShadowSetup::configure(const Config& configuration) {
|
||||
|
@ -374,6 +375,16 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
|
|||
bias._constant, bias._slope);
|
||||
}
|
||||
|
||||
// copy paste the values for the shadow params:
|
||||
if (!_globalShadowObject.first) {
|
||||
LightStage::Shadow::Schema schema;
|
||||
_globalShadowObject.first = std::make_shared<gpu::Buffer>(sizeof(LightStage::Shadow::Schema), (const gpu::Byte*) &schema);
|
||||
}
|
||||
_globalShadowObject.first->setData(globalShadow->getBuffer()._size, globalShadow->getBuffer()._buffer->getData());
|
||||
|
||||
|
||||
_shadowFrameCache->pushShadow(0, _globalShadowObject.first, _globalShadowObject.second);
|
||||
|
||||
// Now adjust coarse frustum bounds
|
||||
auto frustumPosition = firstCascadeFrustum->getPosition();
|
||||
auto farTopLeft = firstCascadeFrustum->getFarTopLeft() - frustumPosition;
|
||||
|
@ -422,6 +433,8 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c
|
|||
queryResolution.x = int(queryResolution.x * _coarseShadowFrustum->getWidth() / firstCascadeFrustum->getWidth());
|
||||
queryResolution.y = int(queryResolution.y * _coarseShadowFrustum->getHeight() / firstCascadeFrustum->getHeight());
|
||||
output.edit1() = queryResolution;
|
||||
|
||||
output.edit3() = _shadowFrameCache;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
// There is one AABox per shadow cascade
|
||||
using Input = LightStage::FramePointer;
|
||||
using Output = render::VaryingArray<AABox, SHADOW_CASCADE_MAX_COUNT>;
|
||||
using Output = render::VaryingSet2<render::VaryingArray<AABox, SHADOW_CASCADE_MAX_COUNT>, LightStage::ShadowFramePointer>;
|
||||
using Config = RenderShadowTaskConfig;
|
||||
using JobModel = render::Task::ModelIO<RenderShadowTask, Input, Output, Config>;
|
||||
|
||||
|
@ -101,7 +101,7 @@ signals:
|
|||
class RenderShadowSetup {
|
||||
public:
|
||||
using Inputs = LightStage::FramePointer;
|
||||
using Outputs = render::VaryingSet3<RenderArgs::RenderMode, glm::ivec2, ViewFrustumPointer>;
|
||||
using Outputs = render::VaryingSet4<RenderArgs::RenderMode, glm::ivec2, ViewFrustumPointer, LightStage::ShadowFramePointer>;
|
||||
using Config = RenderShadowSetupConfig;
|
||||
using JobModel = render::Job::ModelIO<RenderShadowSetup, Inputs, Outputs, Config>;
|
||||
|
||||
|
@ -118,6 +118,9 @@ private:
|
|||
float _slope;
|
||||
} _bias[SHADOW_CASCADE_MAX_COUNT];
|
||||
|
||||
LightStage::ShadowFrame::Object _globalShadowObject;
|
||||
LightStage::ShadowFramePointer _shadowFrameCache;
|
||||
|
||||
void setConstantBias(int cascadeIndex, float value);
|
||||
void setSlopeBias(int cascadeIndex, float value);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue