Hello ?
I’m trying to achieve a 2D shadow effect in OpenGL by rendering my shadows polygons to a texture and then rendering that texture as a full-screen quad to the back buffer. The texture is the same dimensions as the screen, the quad is rendered with the coordinates of (-1.0f,-1.0f), (1.0f,-1.0f),(1.0f,1.0f), and (-1.0f,1.0f) and with the texture coordinates (0.0f,0.0f),(1.0f,0.0f),(1.0f,1.0f), and (0.0f,1.0f).
However, I can’t seem to get the texture’s pixels to line up property with the back buffer. This results in a wobbling/dancing effect as the view scrolls around. Compare the following two videos:
In this video, I render the shadow polygons to the offscreen buffer/texture and then reset the transformation matrix and render the texture to the back buffer as a full-screen quad, as described above. Notice the wobble? It’s most evident on the horizontal and vertical shadows on the top right. (Please excuse the general framerate stutter as my screen-recording software tries to keep up.)
In the next video, I render the shadow polygons directly the back buffer rather than to the offscreen texture first:
No wobble.
I’ve tried manipulating the texture coordinates in various ways, such as by moving them “inwards” by 0.5f/texturewidth and 0.5f/textureheight, but the wobble remains. Also, switching from GL_LINEAR to GL_NEAREST does not solve the issue.
Any thoughts? Thanks!