dunno if this is an advanced question… sopelase move it if its not…
im havin trouble projection my shadowmap onto my geoemtry…
right now all i want to do is to make it visible… (no real shadow calculations)
sooo first ive rendered the scene depth to a FBO… this is ok ive rendred the FBO and it looks as it should…
but when i try to project the FBO onto the geoemtry it gets all black… what am i doing wrong?
glActiveTexture(GL_TEXTURE3);
DepthFBO.Begin();
gluLookAt( 500,500,500, // Look from the light's position
0.0f, -0.0f, 0.0f,
0.0f, 1.0f, 0.0f );
glGetFloatv(GL_MODELVIEW_MATRIX, lightproj_matrix);
glMatrixMode( GL_TEXTURE );
glLoadIdentity();
glTranslatef( 0.5f, 0.5f, 0.5f ); // Offset
glScalef( 0.5f, 0.5f, 0.5f ); // Bias
gluPerspective( 45.0, (GLdouble)1024 / 786, 0.1, 5000.0 );
glMultMatrixf( lightproj_matrix );
glMatrixMode( GL_MODELVIEW );
Terrain->DepthShader->use();
Terrain->Render();
Terrain->DepthShader->disable;
DepthFBO.End();
glActiveTexture(GL_TEXTURE2);
MainFBO.Begin();
m_Cam->Update();
Terrain->Shader->use();
Terrain->Shader->sendUniform("ShadowMap", 3);
Terrain->Shader->sendUniform("lightprojmatrix", lightproj_matrix, false,4);
Terrain->Render();
Terrain->Shader->disable;
MainFBO.End();
and the shader code…
//VERTEX SHADER
gl_Position = gl_ModelViewProjectionMatrix * vec4(WorldPos, 1.0);
lightProj = lightprojmatrix * vec4(WorldPos, 1.0);
//lightProj= gl_TextureMatrix[0]* vec4(WorldPos, 1.0); // TRIED BOTH VARIATIONS
// if i project using the current models matrix i get greyscale colours.. even if its wrong.. but atleast its not black which is the case with the previous 2...
//lightProj = gl_ModelViewProjectionMatrix * vec4(WorldPos, 1.0);
}
// FRAGMENT
void main()
{
vec2 pos = lightProj.xy/lightProj.w;
vec4 shadmap = texture2D(ShadowMap, gl_TexCoord[0].st);
gl_FragColor = shadmap;
}
the only thing i can think of as incorrect is the retreived lightprojectamtrix…