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

Thread: Problem with fragment.position, ATI specific

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    France
    Posts
    16

    Problem with fragment.position, ATI specific

    Hello,

    I have a simple pair of programs, and basically I output the fragment.position / viewport size as the fragment color, simply to check the values that are returned by the shader.

    On any NV hardware, using fragment.position or f[WPOS] does not make any problem. The resulting coordinates are accurate and can be used to sample the appropriate texel in a RECT texture, or a 2D texture after normalization.

    On my ATI configuration X800 PRO/GTO, Catalyst 6.4, the fragment value is not correct all the times: there's an offset added to the result, that rely on the rendered geometry (as if it was a low accuracy interpolation of the vertex coordinates after the MVP): Two different geometries at different depths don't produce neighboring fragment.positions at neighboring pixels on screen.

    I can't figure out any reason for that. Anyone has an idea or ever met such a problem ?

    Thanks in advance.

  2. #2
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Problem with fragment.position, ATI specific

    The X800 doesn't have the VPOS register, so it will be implemented by interpolating and doing a division in the fragment shader. With 24bit precision and an RCP instruction that I think is actually a bit or two less precise than that I guess there may be some slight error. How big offset are we talking about?

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    France
    Posts
    16

    Re: Problem with fragment.position, ATI specific

    Hmmm, I was guessing that, but I was not aware of the real accuracy beyond. I've tried the manual interpolation and I got exactly the same result as for fragment.position.

    The resulting offset is in the [0-2] pixel range. This is very problematic, because the image composition we do uses a lot of screen space textures (you can see our product on nvidia hardware at www.redway3d.com . There's a trial version that you can download: It's a real-time ray tracer working within a regular 3d engine).
    For example, I render shadows on a separate screen space texture and read it at the current window pixel coordinates at the time I render the geometry pass for a given light. This because we have many different ways to compute shadows (shadow maps, ray traced, area shadows, etc...). This why I need - amongst other usages - an access to correct window coordinates for every rendered fragment.

    Could you tell me the versions of ATI boards that have a VPOS register implementation ? Or do you have an idea on the way to bypass this lack of accuracy ?

    Thanks

  4. #4
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Problem with fragment.position, ATI specific

    The X1300 and up supports the VPOS register. Not sure if there's any way to work around the accuracy problem on older cards. Floating point numbers give best accuracy around zero though, so one thing that might want to try is to interpolate in clip space coordinates (-1 to 1) instead, then scale and bias in the fragment shader, rather than have that baked into the interpolation from the vertex shader.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    France
    Posts
    16

    Re: Problem with fragment.position, ATI specific

    Thanks for your quick reply !
    I'll try getting closer to 0 to see if that works.

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    France
    Posts
    16

    Re: Problem with fragment.position, ATI specific

    Ooops, one thing I forgot to ask you... Do you know which of the FireGL cards support VPOS ?
    Thanks again !
    Renaud.

  7. #7
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Problem with fragment.position, ATI specific

    The FireGL V7300 and up should support it.

  8. #8
    Junior Member Newbie
    Join Date
    Mar 2004
    Location
    France
    Posts
    16

    Re: Problem with fragment.position, ATI specific

    Thanks !

  9. #9
    Intern Contributor macarter's Avatar
    Join Date
    Mar 2004
    Location
    Saint Louis, Missouri, USA
    Posts
    67

    Re: Problem with fragment.position, ATI specific

    The interpolator for fragment color is limited to about 12 bits on many (all?) ATI cards. Use a texture coordinate instead of the fragment color. It will have much higher accuracy.

Posting Permissions

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