I'm rendering a frameBuffer texture to another frameBuffer for multiple pass shadows.
The problem is it's not aligning correctly.
Heres my code:
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO[totalLights]);
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderMultipassShadows.Use();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depthCubemap[0]);
glUniform1i(glGetUniformLocation(shaderMultipassShadows.Program, "depthMap"), 0);
RenderQuad();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
geometry shade:
#version 330 core
layout (triangles) in;
layout (triangle_strip, max_vertices=18) out;
void main()
{
for(int face = 0; face < 6; ++face)
{
gl_Layer = face; // built-in variable that specifies to which face we render.
for(int i = 0; i < 3; ++i) // for each triangle's vertices
{
gl_Position = gl_in.gl_Position;
EmitVertex();
}
EndPrimitive();
}
}
vertex shader:
#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoords;
out vec2 TexCoords;
void main()
{
gl_Position = vec4(position, 1.0f);
TexCoords = texCoords;
}
#version 330 core
in vec2 TexCoords;
out vec4 FragColor;
uniform samplerCube depthMap;
void main()
{
FragColor = textureCube(depthMap, vec3(TexCoords, 1.0f));
}
Thank you.