fixed different lightVP during shadowmap / scene rendering

This commit is contained in:
Eikthyrnir 2024-02-07 11:22:51 +01:00
parent 6af9e40fd7
commit b80c946b53
2 changed files with 4 additions and 3 deletions

View File

@ -2,7 +2,7 @@
float AMBIENT = 0.03;
float PI = 3.14;
float shadowBias = 0.0;
float shadowBias = 0.01;
uniform sampler2D depthMap;

View File

@ -45,6 +45,7 @@ GLuint programTest;
GLuint programTex;
GLuint programDepth;
glm::mat4 lightVP;
Core::Shader_Loader shaderLoader;
@ -130,7 +131,6 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depthMap);
glm::mat4 lightVP = glm::ortho(-3.f, 3.f, -3.f, 3.f, 1.f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glUniformMatrix4fv(glGetUniformLocation(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
@ -182,7 +182,8 @@ void renderShadowapSun() {
glUseProgram(programDepth);
//viewProjection matrix
glm::mat4 lightVP = glm::ortho(-2.9f, 2.2f, -1.1f, 2.7f, 1.f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
lightVP = glm::ortho(-2.9f, 2.2f, -1.1f, 2.7f, 1.f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
//lightVP = glm::ortho(-10.f, 10.f, -10.f, 10.f, 1.f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
//draw
//lamp