OpenGL ES (1.0 and 2.0) does not offer a way to read the depth buffer. You
can fake it in 2.0 by using a custom shader to render the scene in an FBO.
Here's the fragment shader I've used in the past to achieve this:

// uniform float UNI_near;
// uniform float UNI_far;

void main() {
    // Non-linear depth value
    float z = gl_FragCoord.z;
    // Near and far planes from the projection
    float n = UNI_near;
    float f = UNI_far;
    // Linear depth value
    z = (2.0 * n) / (f + n - z * (f - n));

    gl_FragColor = vec4(z, z, z, 1.0);
}

On Mon, Nov 7, 2011 at 12:48 PM, Latimerius <[email protected]>wrote:

> On Mon, Nov 7, 2011 at 6:01 PM, saex <[email protected]> wrote:
> > Yes Latimerius, i think that i dont have to pass 0 as winZ parameter,
> > but i dont know how to get the Z value from the depth buffer. I'm
> > programming for Android 1.5 and openGL ES1, i didn't find a working
> > way to obtain winZ value on google after hours of searching :(
> >
> > Did you know how to do it?
>
> Actually, if you're stuck with GL ES 1.0, unfortunately I'm not aware
> of a way to read the depth buffer. I'm no expert on legacy GL ES
> though so you might want to consider asking on a GL ES forum -
> although there might not be a direct way to read the depth buffer
> under GL ES 1.0 someone could know a work-around.
>
> If you can't use GL to do the unprojection you can still compute it
> manually.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
[email protected]

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to