Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a motion blur using OpenGL immediate mode, basically it involves saving screen to texture, then rendering blended texture back (let's skip the details) with something like this:

        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0); // Bottom Left Of The Texture and Quad
        glTexCoord2f(1.0f, 1.0f); glVertex2f(800, 0);   // Bottom Right Of The Texture and Quad
        glTexCoord2f(1.0f, 0.0f); glVertex2f(800,  600);    // Top Right Of The Texture and Quad
        glTexCoord2f(0.0f, 0.0f); glVertex2f(0,  600);

My problem is: When I use the motion blur, seemly the blended screen get 1 pixel shifted to the opposite of (0, 0), resulting in everything getting blurry, not only the moving stuff.

The stronger I apply the effect, the stronger everything else blurs (as seemly every frame of blur get 1 more pixel shifted).

How I fix that?

share|improve this question
up vote 4 down vote accepted

The texel co-ordinates, if you have bilinear filtering, are falling between the texels rather than being centered.

You either need to to add half a texel to the UVs, or turn off filtering.

share|improve this answer
Thank you. I actually figured that I could turn off filtering, and it fixed. – speeder Oct 8 '10 at 16:49
But I am still wondering, how I add half a texel... or stuff like that. – speeder Oct 8 '10 at 16:50
To add half a texel, you need to adjust your texture co-ordinates. Co-ordinates are normalised to be between 0 to 1, so if you have a 800x600 texture, you need to add 1/1600 and 1/1200 to the u and v values respectively. – JasonD Oct 8 '10 at 21:48
I don't think this answer is correct in the interpretation of the results. The code in the question ought to map texels to pixels exactly as it stands, if the modelview/projection are set correctly (identity for MV and projection of glOrtho(0,0,w,h,...). So I'd bet that's where the issue is. – Bahbar Oct 12 '10 at 20:54
Well yes, you're probably right that there's something else going on here. However I think my answer is correct as far as the basic problem - something is causing the texels to be sampled in the wrong place, by just enough that it looks wrong with filtering on, but works if it's turned off. – JasonD Oct 13 '10 at 5:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.