Merge remote-tracking branch 'origin/deffered_rendering' into gui
Conflicts: assets src/GameWorld.cpp
This commit is contained in:
+46
-2
@@ -17,10 +17,10 @@ Renderer::Renderer()
|
||||
CAtt = 1.0f;
|
||||
LAtt = 0.0f;
|
||||
QAtt = 3.0f;
|
||||
m_ShadowMapRes = 2048*8;
|
||||
m_ShadowMapRes = 2048*6;
|
||||
m_SunPosition = glm::vec3(0, 3.5f, 10);
|
||||
m_SunTarget = glm::vec3(0, 0, 0);
|
||||
m_SunProjection = glm::ortho<float>(-200.f, 200.f, -200.f, 200.f, -100, 200);
|
||||
m_SunProjection = glm::ortho<float>(10.f, -10.f, 10.f, -10.f, 10.f, -10.f);
|
||||
/* Lights = 0;*/
|
||||
}
|
||||
|
||||
@@ -572,6 +572,15 @@ void Renderer::FrameBufferTextures()
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
//Generate and bind normal texture
|
||||
glGenTextures(1, &m_fSpecularTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
/*glGenTextures(1, &m_fShadowTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fShadowTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
@@ -588,6 +597,7 @@ void Renderer::FrameBufferTextures()
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fDiffuseTexture, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_fPositionTexture, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_fNormalsTexture, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fSpecularTexture, 0);
|
||||
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fShadowTexture, 0);
|
||||
|
||||
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
@@ -734,6 +744,11 @@ void Renderer::DrawFBOScene()
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.Texture);
|
||||
if (texGroup.NormalMap)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.NormalMap);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||
}
|
||||
}
|
||||
@@ -826,3 +841,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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user