using framebuffer Depth component as RGB texture

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

using framebuffer Depth component as RGB texture

jordiperez
Hello,

I am using OpenGL ES and I want to transfer from the framebuffer, the depth component to a RGB texture.

1. I create the texture trying several modes:

gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_INTENSITY, width, height, 0,
                        GL.GL_INTENSITY, GL.GL_UNSIGNED_BYTE, null);

tryed also with GL.GL_DEPTH_COMPONENT and GL_FLOAT pixel format.


2.after render to the frameBuffer i fill the texture with:

        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glBindTexture(GL.GL_TEXTURE_2D, dstTexture.getID());
        gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT, 0, 0, 512, 512, 0);

3. when i use the texture it is poor defined, i've created a plane that comes from the camera far away and i don't see black colour when it is near the camera.


Do somebody have working code to make it work?
Reply | Threaded
Open this post in threaded view
|

Re: using framebuffer Depth component as RGB texture

Demoscene Passivist
Administrator
U may have a look at my blog for a JOGL2 fixedfunction shadowmapping routine: http://copypastaresearch.tumblr.com/post/1454280770/ported-another-of-my-old-routines-to-jogl2-this

It copies the depthbuffer from the framebuffer to a texture and also includes a visualization for the depthbuffer when u set the mShowShadowMap boolean to true. It does not use OpenGL ES but I guess u should be able to easiely modify it for ES.
Reply | Threaded
Open this post in threaded view
|

Re: using framebuffer Depth component as RGB texture

jordiperez
Thanks for the reply.

I have found a solution for my code above wich is working fine, the mistake on my program was the gluPerspective neacr clip distance, setting it with a mimimum value of 10.0 the DEPTH_component is get very well defined, inclusive using a small GL_LUMINANCE pixel format.