diff --git a/assets b/assets index 672e8a2..cdee701 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 672e8a2b11ecaafc95a5b0286b5ec310c62438ad +Subproject commit cdee7015793193f0e78a2b75b25e3a2c07881632 diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 19026b2..160498b 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -17,14 +17,14 @@ void GameWorld::Initialize() auto ground = CreateEntity(); auto transform = AddComponent(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(ground, "Model"); model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; auto box = AddComponent(ground, "Box"); - box->Width = 200; + box->Width = 400; box->Height = 5; - box->Depth = 200; + box->Depth = 400; auto physics = AddComponent(ground, "Physics"); physics->Mass = 10; diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 2e781a0..d78f0b7 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -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(-200.f, 200.f, -200.f, 200.f, -100, 200); + m_SunProjection = glm::ortho(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. +} + + + diff --git a/src/Renderer.h b/src/Renderer.h index e1a2aec..9053d92 100755 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -141,6 +141,8 @@ private: void DrawLightScene(); void BindFragDataLocation(); glm::mat4 CreateLightMatrix(Light &_light); + void UpdateSunProjection(); + GLuint CreateQuad(); void DrawDebugShadowMap();