Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn

This commit is contained in:
ViktorLjung
2014-03-13 19:39:23 +01:00
3 changed files with 10 additions and 8 deletions
+5 -3
View File
@@ -16,7 +16,7 @@ Renderer::Renderer()
m_ShadowMapRes = 2048*2;
m_SunPosition = glm::vec3(0, 0.3f, 10);
m_SunTarget = glm::vec3(0, 0, 0);
m_SunProjection = glm::ortho<float>(-200, 200, -10, 100, -800, 400);
m_SunProjection = glm::ortho<float>(-200, 200, -10, 100, -800, 800);
Lights = 0;
}
@@ -209,14 +209,16 @@ void Renderer::DrawScene()
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
//DrawModels(m_ShaderProgram);
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
glm::mat4 depthCameraMatrix = biasMatrix * depthCamera;
glm::mat4 MVP;
glm::mat4 depthMVP;
for (auto tuple : ModelsToRender)
{
Model* model;
glm::mat4 modelMatrix;
std::tie(model, modelMatrix) = tuple;
MVP = cameraMatrix * modelMatrix;
glm::mat4 depthMVP = biasMatrix * depthCamera * modelMatrix;
depthMVP = depthCameraMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
@@ -243,7 +245,7 @@ void Renderer::DrawShadowMap()
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glCullFace(GL_FRONT);
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
glViewport(0, 0, m_ShadowMapRes, m_ShadowMapRes);
+2 -2
View File
@@ -51,9 +51,9 @@ void main() {
//bias = clamp(bias, 0.0, 0.01);
float visibility = 1.0;
if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0) {
float bias = 0.003;
float bias = 0.0005;
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
if (shadowMapValue.z < Input.ShadowCoord.z - bias) {
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1)) {
visibility = 0.5;
}
}
+3 -3
View File
@@ -71,11 +71,11 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
glm::vec3 Ship_Right = glm::vec3(glm::vec4(1, 0, 0, 0));
glm::vec3 Ship_Forward = glm::vec3(glm::vec4(0, 0, 1, 0));
float TurnSpeed = 2.0f;
float TurnSpeed = 1.0f;
glm::vec3 Euler = glm::eulerAngles(transform->Orientation);
if(input->KeyState[GLFW_KEY_LEFT]) {
transform->Position -= Ship_Right * (float)dt * m_PlayerSpeed;
transform->Position -= Ship_Right * (float)dt * (m_PlayerSpeed + Euler.z);
if(Euler.z < 10.f)
{
@@ -91,7 +91,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
}
}
else if(input->KeyState[GLFW_KEY_RIGHT]) {
transform->Position += Ship_Right * (float)dt * m_PlayerSpeed;
transform->Position += Ship_Right * (float)dt * (m_PlayerSpeed - Euler.z);
if(Euler.z > -10.f)
{