From 077db8b04e19ff03497da19070fc1f915ef34276 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Fri, 16 Mar 2018 11:40:10 +0100 Subject: [PATCH] Fixed wrong shadow maps on first start --- src/modules/RenderModule.cc | 9 ++++----- src/modules/RenderModule.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index e139e46..7a232f8 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -177,6 +177,10 @@ void Light::Initialize() { void Light::UpdateMatrices() { mCamera.mIsOrthographic = true; + mCamera.mEye = mPosition; + mCamera.mPoi = mPosition - mDirection; + mCamera.mUp = Vector3f (0.0f, 1.0f, 0.0f); + mCamera.mProjectionMatrix = Ortho (-mBBoxSize * 0.5f, mBBoxSize * 0.5f, -mBBoxSize * 0.5f, mBBoxSize * 0.5f, mNear, mFar); mCamera.mViewMatrix = LookAt (mCamera.mEye, mCamera.mPoi, mCamera.mUp); @@ -190,10 +194,6 @@ void Light::DrawGui() { ImGui::SliderFloat("Near", &mNear, -10.0f, 50.0f); ImGui::SliderFloat("Far", &mFar, -10.0f, 50.0f); - mCamera.mEye = mPosition; - mCamera.mPoi = mPosition - mDirection; - mCamera.mUp = Vector3f (0.0f, 1.0f, 0.0f); - ImVec2 content_avail = ImGui::GetContentRegionAvail(); ImGui::Checkbox("Draw Light Depth", &sRendererSettings.DrawLightDepth); @@ -508,7 +508,6 @@ void Renderer::RenderScene(RenderProgram &program, const Camera& camera) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mLight.mShadowMapTarget.mDepthTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); program.SetInt("uShadowMap", 0); glActiveTexture(GL_TEXTURE1); diff --git a/src/modules/RenderModule.h b/src/modules/RenderModule.h index ee82034..ef4ceb6 100644 --- a/src/modules/RenderModule.h +++ b/src/modules/RenderModule.h @@ -36,7 +36,7 @@ struct Light { mPosition (Vector3f(0.f, 3, 0.0f)), mDirection (Vector3f(1.f, 1.f, 1.f)), mShadowMapBias (0.004f), - mShadowMapSize (2048), + mShadowMapSize (1024), mNear (-10.0f), mFar (15.f), mBBoxSize (35.f),