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

Thread: Creating a depth texture to use in GLSL

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    11

    Creating a depth texture to use in GLSL

    I'm trying to figure out how to create a depth texture that I can use from frame to frame in C++ / GLSL.

    Lets say on frame number one I set gl_FragDepth of a few random pixels to 0.5. Before rendering frame 2, I'd like to apply the depth state to a texture. This way, in frame 2, I can determine which texels are at 0.5 so I can further manipulate them.

    I can't seem to find any clear tutorials/reference/instructions on how to do this.

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    6,031

    Re: Creating a depth texture to use in GLSL

    Assuming input from your previous thread is valid, you aren't really using the depth value for actual depth comparison. So it doesn't need to be a depth texture at all; it can just be a floating-point texture that you write a value to.

    In either case however, what you're looking for is direct rendering to a texture. To do that, you need to use Framebuffer Objects.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    11

    Re: Creating a depth texture to use in GLSL

    Thank you! Exactly what I'm looking for.


    And you're right... I really just need numbers to compare. Depth seemed like the natural thing to use.

Posting Permissions

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