Working on shadows

This commit is contained in:
Tleety
2014-05-17 14:00:26 +02:00
parent ccd1393dac
commit 67778f391a
4 changed files with 37 additions and 6 deletions
+1 -1
Submodule assets updated: 672e8a2b11...cdee701579
+3 -3
View File
@@ -17,14 +17,14 @@ void GameWorld::Initialize()
auto ground = CreateEntity();
auto transform = AddComponent<Components::Transform>(ground, "Transform");
transform->Position = glm::vec3(0, -5, 0);
transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
transform->Scale = glm::vec3(800.0f, 10.0f, 800.0f);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
auto model = AddComponent<Components::Model>(ground, "Model");
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
auto box = AddComponent<Components::Box>(ground, "Box");
box->Width = 200;
box->Width = 400;
box->Height = 5;
box->Depth = 200;
box->Depth = 400;
auto physics = AddComponent<Components::Physics>(ground, "Physics");
physics->Mass = 10;
+31 -2
View File
@@ -17,10 +17,10 @@ Renderer::Renderer()
CAtt = 1.0f;
LAtt = 0.0f;
QAtt = 3.0f;
m_ShadowMapRes = 2048*8;
m_ShadowMapRes = 2048*16;
m_SunPosition = glm::vec3(0, 3.5f, 10);
m_SunTarget = glm::vec3(0, 0, 0);
m_SunProjection = glm::ortho<float>(-200.f, 200.f, -200.f, 200.f, -100, 200);
m_SunProjection = glm::ortho<float>(10.f, -10.f, 10.f, -10.f, 10.f, -10.f);
/* Lights = 0;*/
}
@@ -782,3 +782,32 @@ glm::mat4 Renderer::CreateLightMatrix(Light &_light)
return model;
}
void Renderer::UpdateSunProjection()
{
glm::vec3 NDCCube[] =
{
glm::vec3(-1.f, -1.f, -1.f),
glm::vec3(1.f, -1.f, -1.f),
glm::vec3(-1.f, 1.f, -1.f),
glm::vec3(1.f, 1.f, -1.f),
glm::vec3(-1.f, -1.f, 1.f),
glm::vec3(1.f, -1.f, 1.f),
glm::vec3(-1.f, 1.f, 1.f),
glm::vec3(1.f, 1.f, 1.f)
};
glm::mat4 inverseProjectionViewMatrix = glm::inverse(m_Camera->ViewMatrix()) * glm::inverse(m_Camera->ProjectionMatrix());
//Also * with world matrix for light
for(auto corner : NDCCube)
{
//corner *= inverseProjectionViewMatrix;
}
//Calculate the bounding box of the transformed frustum corners. This will be the view frustum for the shadow map.
//Pass the bounding box's extents to glOrtho or similar to set up the orthographic projection matrix for the shadow map.
}
+2
View File
@@ -141,6 +141,8 @@ private:
void DrawLightScene();
void BindFragDataLocation();
glm::mat4 CreateLightMatrix(Light &_light);
void UpdateSunProjection();
GLuint CreateQuad();
void DrawDebugShadowMap();