FBO with GL_TEXTURE_CUBE_MAP

This topic contains 5 replies, has 3 voices, and was last updated by  JackAsser 5 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30835

    JackAsser
    Member

    Is it possible to create a depth component only FBO targeting a GL_TEXTURE_CUBE_MAP. What I want to do is to extend my spot light shadow mapper into an omni directional shadow mapper by attaching a cube texture to the FBO instead.

    I’m fully aware that I would need to render the scene in 6 passes, one for each side of the cube face since GLES 2 do not have geometry shaders, but that’s ok. There’s still a big win for only one texture unit (samplerCube) when doing the shadow depth tests, instead of 6 different samplers and choosing cube face manually.

    I can’t get this to work unfortunately. I get incomplete attachment all the time.

    Code:
    glGenTextures(1, &depthTexture);

                

                GLenum target = cubic?GL_TEXTURE_CUBE_MAP:GL_TEXTURE_2D;

                glBindTexture(target, depthTexture);

                glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

                glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

                glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

                glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

                

                if (!cubic)

                {

                   glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, depthType, NULL);

                   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);

                }

                else

                {

                   for (int i=0; i<6; i++)

                        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, depthType, NULL);

                   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, depthTexture, 0);

                }

    #35751

    JackAsser
    Member

    Still haven’t been able to get this working… 🙁 Maybe it’s impossible to render to a cube depth map in GLES2?

    #35752

    Jack,

       I wrote a wiki article some time ago about using FBOs with the PowerVR OpenGL ES drivers that might help:

    http://processors.wiki.ti.com/index.php/Render_to_Texture_with_OpenGL_ES

    Capturing the depth image into a texture requires the
    OES_depth_texture extension which was only available beginning with the PowerVR OpenGL ES drivers build from their
    1.4 DDK.
    Check if the driver you are using has this extension declared.

    Regards, Clay

    #35753

    JackAsser
    Member

    I can already capture the depth to a texture2d but not to a texturecubemap target. Is that possible?

    #35754

    BobGardner
    Member

    Hi JackAsser,

    Sadly, what your attempting to do is not supported by the current specification for OpenGL ES. If your using GL_DEPTH_COMPONENT then your only option is GL_TEXTURE_2D.

    Apologies,

    BobBobGardner2012-04-23 11:37:14

    #35755

    JackAsser
    Member

    Yeps, so I assumed by now. I’m using an alternative path where I render the depth values into the color channels instead. For 16-bit float precision I choose the OES_HALF_FLOAT format for that. This way I can reuse the cube map for up to 4 light sources at the same time, each using one channel at 16-bit float precision.

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.