Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 13

Thread: Choppy movement with floats

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    12

    Choppy movement with floats

    The footage pretty much shows the problem:
    http://www.youtube.com/watch?v=cOKF3jj-sPI

    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.

  2. #2
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    315
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    12
    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.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Oct 2007
    Location
    Phoenix, AZ
    Posts
    109
    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?

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2012
    Posts
    12
    It is textured quads, I move this text by 0.01f each frame.
    Last edited by SoulSharer; 11-23-2012 at 11:19 AM.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Oct 2007
    Location
    Phoenix, AZ
    Posts
    109
    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);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •