Shadow mapping works 99%
This commit is contained in:
@@ -64,7 +64,7 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
|
||||
float uniform = minZ + range * p;
|
||||
float d = cascadeSplitLambda * (log - uniform) + uniform;
|
||||
cascadeSplits[i] = (d - nearClip) / clipRange;
|
||||
splitDepths[i] = farClip - cascadeSplits[i] * clipRange;
|
||||
splitDepths[i] = d;
|
||||
cascades[i].viewParams.clear();
|
||||
}
|
||||
cascadeSplitsBuffer->updateContents(0, sizeof(float) * NUM_CASCADES, splitDepths);
|
||||
@@ -76,8 +76,8 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
|
||||
float splitDist = cascadeSplits[i];
|
||||
|
||||
Array<Vector> frustumCorners = {
|
||||
Vector(-1.0f, 1.0f, 1.0f), Vector(1.0f, 1.0f, 1.0f), Vector(1.0f, -1.0f, 1.0f), Vector(-1.0f, -1.0f, 1.0f),
|
||||
Vector(-1.0f, 1.0f, 0.0f), Vector(1.0f, 1.0f, 0.0f), Vector(1.0f, -1.0f, 0.0f), Vector(-1.0f, -1.0f, 0.0f),
|
||||
Vector(-1.0f, 1.0f, 1.0f), Vector(1.0f, 1.0f, 1.0f), Vector(1.0f, -1.0f, 1.0f), Vector(-1.0f, -1.0f, 1.0f),
|
||||
};
|
||||
|
||||
for (auto& c : frustumCorners) {
|
||||
@@ -111,7 +111,7 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
|
||||
Vector cameraPos = frustumCenter - lightDir * -minExtents.z;
|
||||
Matrix4 viewMatrix = glm::lookAt(cameraPos, frustumCenter, Vector(0, 1, 0));
|
||||
Matrix4 projectionMatrix =
|
||||
orthographicProjection(minExtents.x, maxExtents.x, minExtents.y, maxExtents.y, maxExtents.z - minExtents.z, 0.0f);
|
||||
orthographicProjection(minExtents.x, maxExtents.x, minExtents.y, maxExtents.y, 0.0f, maxExtents.z - minExtents.z);
|
||||
Matrix4 viewProjectionMatrix = projectionMatrix * viewMatrix;
|
||||
viewParams = {
|
||||
.viewMatrix = viewMatrix,
|
||||
@@ -194,7 +194,7 @@ void ShadowPass::render() {
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SE_CULL_MODE_NONE,
|
||||
.depthBiasEnable = false,
|
||||
.depthBiasEnable = true,
|
||||
.depthBiasConstantFactor = depthBiasConstant,
|
||||
.depthBiasSlopeFactor = depthBiasSlope,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user