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: FBO and GLSL

  1. #1
    Intern Contributor
    Join Date
    Nov 2000
    Location
    Thuringia, Germany
    Posts
    89

    FBO and GLSL

    Hi,

    just a short question, because I found lots of different oppinions about it.

    When rendering to a FBO texture, can I use gl_FragCoord in my Fragment Shader to get the x and y pixel screencoordinate? (FBO texture is same size as OpenGL-Window)

    I heard about that it should give unpredictable results....


    Greetings,
    Sebastian

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Re: FBO and GLSL

    gl_FragCoord will return the texture coordinates you assigned to the vertex you're processing - as usual.

  3. #3
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: FBO and GLSL

    Since when gl_FragCoord return texture coordinates? oO
    I thought it will return window-space coordinates, actually (I would still prefer the device-independent coordinates). No idea how it works with FBO, why won't you try it out?

  4. #4
    Intern Newbie
    Join Date
    Jan 2005
    Posts
    35

    Re: FBO and GLSL

    gl_FragCoord returns the pixel position of a fragment even with FBO's. In order to turn this into a normalized texture coordinate you would need to divide by the dimensions of the screen aligned quad you rendered (if that's how you generated fragments). It doesn't sound like you care about that though.

  5. #5
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Re: FBO and GLSL

    d'oh i misread sry -.-

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

    Re: FBO and GLSL

    Of course, using gl_FragCoord to get texture coordinates is usually not recommended, especially on previous generation hardware. Use an interpolator instead.

Posting Permissions

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