Fixed wrong shadow maps on first start
parent
fc58ba5513
commit
077db8b04e
|
@ -177,6 +177,10 @@ void Light::Initialize() {
|
||||||
void Light::UpdateMatrices() {
|
void Light::UpdateMatrices() {
|
||||||
mCamera.mIsOrthographic = true;
|
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.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);
|
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("Near", &mNear, -10.0f, 50.0f);
|
||||||
ImGui::SliderFloat("Far", &mFar, -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();
|
ImVec2 content_avail = ImGui::GetContentRegionAvail();
|
||||||
|
|
||||||
ImGui::Checkbox("Draw Light Depth", &sRendererSettings.DrawLightDepth);
|
ImGui::Checkbox("Draw Light Depth", &sRendererSettings.DrawLightDepth);
|
||||||
|
@ -508,7 +508,6 @@ void Renderer::RenderScene(RenderProgram &program, const Camera& camera) {
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, mLight.mShadowMapTarget.mDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, mLight.mShadowMapTarget.mDepthTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
|
||||||
program.SetInt("uShadowMap", 0);
|
program.SetInt("uShadowMap", 0);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct Light {
|
||||||
mPosition (Vector3f(0.f, 3, 0.0f)),
|
mPosition (Vector3f(0.f, 3, 0.0f)),
|
||||||
mDirection (Vector3f(1.f, 1.f, 1.f)),
|
mDirection (Vector3f(1.f, 1.f, 1.f)),
|
||||||
mShadowMapBias (0.004f),
|
mShadowMapBias (0.004f),
|
||||||
mShadowMapSize (2048),
|
mShadowMapSize (1024),
|
||||||
mNear (-10.0f),
|
mNear (-10.0f),
|
||||||
mFar (15.f),
|
mFar (15.f),
|
||||||
mBBoxSize (35.f),
|
mBBoxSize (35.f),
|
||||||
|
|
Loading…
Reference in New Issue