Choppy movement with floats
The footage pretty much shows the problem:
When I move text slower than a pixel at a time, it doesn't move in subpixels, instead it jumps from pixel to pixel. How can I fix that?
I searched for days, still nothing that could help me with that.
Let me know if I need to show code of some part, I can upload everything, but it'll be a lot to fit in here.
Thanks for the help in advance, hope it will resolve.
Use a multisampled buffer. This will give you sub-pixel coverage, and smooth out the rasterization of your text. The higher the number of samples, the smoother it will become.
Alternatively, you can make the quad 1 pixel larger in each direction, compute the floating point position in screen coordinates where it should appear, and then compare that to the actual GL coords using gl_FragCoord.xy. Use the difference to adjust your texture coordinates.
Thanks for reply, I'm a little concerned about multisampling (performance wise), because DirectX doesn't use it and it has smooth movement out of the box, but OpenGL is not?
Last edited by SoulSharer; 11-23-2012 at 09:57 AM.
Can you explain what you are actually doing?
Is the text in that video a raster image that you are drawing as a textured quad?
Or are the letters a bunch of 3d geometric shapes?
It is textured quads, I move this text by 0.01f each frame.
Last edited by SoulSharer; 11-23-2012 at 11:19 AM.
I just did a test and while the edge of a textured quad is not anti-aliased and will pop pixel to pixel, the texture pixels move smoothly with sub-pixel accuracy.
Are you enabling bi-linear filtering?
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);