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: Depth in OpenGL ES 2.0

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2014
    Posts
    16

    Depth in OpenGL ES 2.0

    I want to organize depth for objects in OpenGL ES 2.0 so that I can specify one object to be in front of other object(s). In OpenGL 3.0 I can use gl_FragDepth and just use uniform variable for depth, but in ES 2.0 this is not defined. What is good practice to do this in OpenGl ES 2.0?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Normally, you do not need to touch gl_FragDepth as it is calculated automatically for you. Unless you do some special tricks with it. Using the depth buffer to sort out fragments of opaque objects is not a "special trick".
    Besides, gl_FragDepth is defined even in the first version of GLSL.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    894
    To have one object rendered on top of everything (independent of the objects actual position in the scene), you can first render everything else, clear the depth buffer, then render your 'special' object.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2014
    Posts
    16
    What I acctually want is to specify depth for each object. Origanally it goes from first to last that is to be rendered. I just want to say which object is beyond another.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    894
    Placing objects in the scene is normally done by specifying a (different) modelview matrix for each object. That, combined with the depth buffer, takes care of visibility.

  6. #6
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    73
    Without questioning why or what you are trying to do, you could check this out:

    https://www.khronos.org/registry/gle...frag_depth.txt

Tags for this Thread

Posting Permissions

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