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 6 of 6

Thread: Fix shimmering without losing blockiness

  1. #1
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    2

    Question Fix shimmering without losing blockiness

    The title says it all. What I'm up for is making a 2d platformer game in which the zoom of the camera would be adjusted for each level. When I implemented this feature, everything that I render started to shimmer once OpenGL has to pick a pixel out of few pixels. I googled it and I found that the way to fix something likes this is with specific texture filtering. However, I tried few of them and none of them seemed to work the way I wanted them to. They make the shimmering go away, however since I'm using 8x and 16x textures mainly, it causes them to be blur, which is another thing I don't want. When I use GL_NEAREST as my mag, min filter, there is shimmering. When I use GL_NEAREST_MIPMAP_NEAREST, for some reason textures look as if they are filtered with GL_LINEAR filter.

    So the thing I'm trying to accomplish is fix shimmering once zoom in/out and keep the blockiness of the textures.

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    2
    What you want is to use mipmapping (GL_LINEAR_MIPMAP_LINEAR) for minification and nearest neighbor filtering for magnification.

    Mipmapping only applies to minification. If you use it as a flag for magnification, you will likely get an OpenGL error and the default filtering(GL_LINEAR) will remain enabled.

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    1. Move the view in multiples of a pixel.
    2. Create the mipmap levels by hand rather than using e.g. glGenerateMipmap() or gluBuild2DMipmaps().

  4. #4
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    2
    Hmm something doesn't seem right. Can't seem to find the solution for shimmering without making textures linear, which I don't want. Does anybody know how does opengl scale everything to full screen when resolutions is much lower than that of full screen? I have 1280*1024 monitor, and when I run my game in 640 * 480 resolution full screen, there is no shimmering. When I try to make my opengl Canvas (glOrtho) with 640 * 480 dimensions onto 1280*1024 window, I get shimmering. Does opengl automatically adjust something when switching to full screen? Because it seems to be the perfect solution I would be looking for.

  5. #5
    Intern Contributor
    Join Date
    May 2013
    Posts
    67
    Just magnify your source image and make a texture from it that for example is 4x4 the size. So that each source image pixel fills 4x4 Pixels of the texture. Then you can use texture filters, without losing the pixel stile look from to much blur.

  6. #6
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by gamingchris3 View Post
    Hmm something doesn't seem right. Can't seem to find the solution for shimmering without making textures linear, which I don't want.
    The solution to shimmering is to move everything in integer multiples of a screen pixel, so that the sample locations remain fixed. If you move objects by fractions of a pixel, the alignment of the screen pixel grid to the texture pixel grid will change, which causes the shimmering.

    Quote Originally Posted by gamingchris3 View Post
    Does anybody know how does opengl scale everything to full screen when resolutions is much lower than that of full screen? I have 1280*1024 monitor, and when I run my game in 640 * 480 resolution full screen, there is no shimmering.
    In this situation, OpenGL doesn't scale anything; the scaling is handled by the monitor.

    Quote Originally Posted by gamingchris3 View Post
    When I try to make my opengl Canvas (glOrtho) with 640 * 480 dimensions onto 1280*1024 window, I get shimmering. Does opengl automatically adjust something when switching to full screen? Because it seems to be the perfect solution I would be looking for.
    You can do almost the same thing yourself by rendering into 640x480 texture using a FBO then rendering the texture into the window. I say "almost", because the monitor's built-in scaling will probably be better than either GL_NEAREST or GL_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
  •