Something about shadowpass
This commit is contained in:
@@ -108,7 +108,7 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
|
||||
Vector maxExtents = Vector(radius);
|
||||
Vector minExtents = -maxExtents;
|
||||
|
||||
Vector lightDir = glm::normalize(-scene->getLightEnvironment()->getDirectionalLight(s).direction);
|
||||
Vector lightDir = glm::normalize(scene->getLightEnvironment()->getDirectionalLight(s).direction);
|
||||
Vector cameraPos = frustumCenter - lightDir * -minExtents.z;
|
||||
Matrix4 viewMatrix = glm::lookAt(cameraPos, frustumCenter, Vector(0, 1, 0));
|
||||
Matrix4 projectionMatrix =
|
||||
@@ -191,8 +191,8 @@ void ShadowPass::render() {
|
||||
.pipelineLayout = collection->pipelineLayout,
|
||||
.rasterizationState =
|
||||
{
|
||||
.cullMode = Gfx::SE_CULL_MODE_FRONT_BIT,
|
||||
.depthBiasEnable = true,
|
||||
.cullMode = Gfx::SE_CULL_MODE_NONE,
|
||||
.depthBiasEnable = false,
|
||||
.depthBiasConstantFactor = depthBiasConstant,
|
||||
.depthBiasSlopeFactor = depthBiasSlope,
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ target_sources(Engine
|
||||
AABB.h
|
||||
Math.h
|
||||
Matrix.h
|
||||
Matrix.cpp
|
||||
Transform.h
|
||||
Transform.cpp
|
||||
Vector.h
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "Matrix.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Matrix4 Seele::orthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane) {
|
||||
return Matrix4{
|
||||
{
|
||||
2.0f / (right - left),
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
2.0f / (top - bottom),
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
1.0f / (farPlane - nearPlane),
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
-(right + left) / (right - left),
|
||||
-(top + bottom) / (top - bottom),
|
||||
farPlane / (farPlane - nearPlane),
|
||||
1.0f,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
@@ -36,32 +37,5 @@ static Matrix4 perspectiveProjection(float fov, float aspect, float nearPlane, f
|
||||
},
|
||||
};
|
||||
}
|
||||
static Matrix4 orthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane) {
|
||||
return Matrix4{
|
||||
{
|
||||
2.0f / (right - left),
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
2.0f / (top - bottom),
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
-2.0f / (nearPlane - farPlane),
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
-(right + left) / (right - left),
|
||||
-(top + bottom) / (top - bottom),
|
||||
-(nearPlane + farPlane) / (nearPlane - farPlane),
|
||||
1.0f,
|
||||
},
|
||||
};
|
||||
}
|
||||
Matrix4 orthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane);
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user