forked from Dynamitos/Seele
More shadowmappingchanges
This commit is contained in:
1 parent
6537459b77
commit
7ab9e8a5e5
7 files changed
+100
-70
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "Window.h"
|
||||
#include "Math/Matrix.h"
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Gfx;
|
||||
@@ -20,37 +21,9 @@ Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
|
||||
Viewport::~Viewport() {}
|
||||
|
||||
Matrix4 Viewport::getProjectionMatrix(float nearPlane, float farPlane) const {
|
||||
Matrix4 correctionMatrix = Matrix4(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 / 2.f, 0, 0, 0, 1 / 2.f, 1);
|
||||
if (fieldOfView > 0.0f) {
|
||||
const float aspect = static_cast<float>(sizeX) / sizeY;
|
||||
const float e = 1.0f / std::tan(fieldOfView * 0.5f);
|
||||
return {
|
||||
{
|
||||
e / aspect,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
-e,
|
||||
0.0f,
|
||||
0.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.5f * (farPlane + nearPlane) / (nearPlane - farPlane),
|
||||
-1.0f,
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
(farPlane * nearPlane) / (nearPlane - farPlane),
|
||||
0.0f,
|
||||
},
|
||||
};
|
||||
return perspectiveProjection(fieldOfView, static_cast<float>(sizeX) / sizeY, nearPlane, farPlane);
|
||||
} else {
|
||||
return correctionMatrix * glm::ortho(orthoLeft, orthoRight, orthoBottom, orthoTop, nearPlane, farPlane);
|
||||
return orthographicProjection(orthoLeft, orthoRight, orthoBottom, orthoTop, nearPlane, farPlane);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user