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: shading program the fiddles with Z values

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    6

    shading program the fiddles with Z values

    Hi all,
    i'm looking for an example of a shader program that changes the depth values, and also would appreciate a short explanation what kind of effects this can produce.

    thank you!

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: shading program the fiddles with Z values

    void main() { gl_FragColor = vec4(1,1,1,1); gl_FragDepth = 1; }

    This function sets the color to white and the depth to 1. Not terribly interesting but I hope you'll get the idea.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    6

    Re: shading program the fiddles with Z values

    ok 10x but i need i was hoping for something more meaningful -
    and also I meant some program the utilizes the incoming fragment's Z value and not setting the output FragDepth.

  4. #4
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    872

    Re: shading program the fiddles with Z values

    gl_FragDepth is read and write variable in fragment shader. How is going to use it is limited by your imagination.

  5. #5
    Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    335

    Re: shading program the fiddles with Z values

    Keep in mind that setting gl_FragDepth may have some performance implications, because early-z and other optimizations can no longer predict the z value (in the same way that happens with alpha-testing).

Posting Permissions

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