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

Thread: 1/4 pixel shift after fragment shaders

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2006
    Location
    Eindhoven, The Netherlands
    Posts
    1

    1/4 pixel shift after fragment shaders

    I'm having a problem that seems to have something to do with antialiasing.

    I am adding some code of my own to an existing OpenGL application. Just before the application calls swapbuffers, I draw a quad on the screen and enable a fragment shader of my own that either outputs 100% blue or 100% white depending on the Y texture coordinate.

    The result is a quad that is part blue near the top, part white near the bottom and has a 75% blue line in between.

    By varying the Y coordinate in the shader at which to switch to white, I cannot get a 100% blue line followed by a 100% white line. There is always a 75% blue line in between.

    What could be the cause of this?

    The application uses ARB_multisample, but although SAMPLE_BUFFERS_ARB is 1, I disable MULTISAMPLE_ARB before I start drawing the quad.

    This image shows the problem. In this case my shader is drawing the black and white bars. The left half is what it should be and the right part is what I get. It looks like a 1/4 pixel shift, but I can't figure out what is causing it.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    669

    Re: 1/4 pixel shift after fragment shaders

    I have no concrete idea what is causing your problem. I just have a hint for you: on R300 based ATI cards, glDisable(GL_MULTISAMPLE_ARB) does nothing, multisampling stays enabled. I donīt know about the newer cards. Another problem might be related to the settings that influence the coverage value of the fragments...

  3. #3
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,967

    Re: 1/4 pixel shift after fragment shaders

    You can't just go disabling a property that's inherently linked to your framebuffer once you start rendering and expect useful results.

    w.r.t. the sample pattern, perhaps you have something like quincunx sample pattern making it tricky to intuitively get a sample sum result binary between two pixels.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    748

    Re: 1/4 pixel shift after fragment shaders

    Have you tried creating a framebuffer that doesn't have Multisample at all and seeing if that fixes it? That'll show if the issue is AA or in your shader.

    It would also help to see the code in your shader and perhaps the code that draws the quad - that might show where the problem is.

  5. #5
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,967

    Re: 1/4 pixel shift after fragment shaders

    quincunx I tell ya.

Posting Permissions

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