I have a simple piece of code that renders a shadow texture using FBO.
On NVIDIA, it works fine, but on ATI, the shadows are distorted.
When I check the shadow texture after rendering it to FBO, it appears to be exactly flipped upside-down compared to NVIDIA result. I can see no other problems with it.
In the code I can’t really find anything that would explain this.
Problematic driver version: 8.523.1.1-080905a-069201C-ATI, ATI OpenGL driver 6.14.10.7287, Windows XP, ATI Mobility FireGL V5200. (Newest driver available for that laptop - I also tried newest Catalyst from ati.com and modded it with Mobility Modder.NET, but it had the same opengl dll and moreover, opengl didn’t work at all, it fell back to software renderer).
Right now I can’t test with any other ATI new enough to support FBO.
It looks to me very much like a driver problem, but it would be curious if nobody else would have run into it. Has anyone seen anything like this?
The code is roughly:
glGenFramebuffersEXT(1, &g_fbo.fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo.fbo);
// Create the render buffer for depth
glGenRenderbuffersEXT(1, &g_fbo.frameBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, g_fbo.frameBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, texwidth, texheight);
int format = GL_DEPTH_COMPONENT32_ARB;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
int texwidth = 4096;
int texheight = 4096;
glTexImage2D(GL_TEXTURE_2D, 0, format,
texwidth, texheight, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 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_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texid, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, g_fbo.frameBuffer);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo.fbo);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
double width = lightDist * tan(lightAngle);
double height = double(width) * double(texwidth) / double(texheight);
glOrtho(-width / 2.0, width / 2.0, -height / 2.0, height / 2.0, nearDist, farDist);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
gluLookAt(lightPos.x, lightPos.y, lightPos.z,
lightFrustumCenter.x, lightFrustumCenter.y, lightFrustumCenter.z,
0.0f, 1.0f, 0.0f);
glViewport(0, 0, texwidth, texheight);
DrawObjects();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);