Problem optimizing dynamic reflections (Cube maps)

This topic contains 1 reply, has 1 voice, and was last updated by  jonkan 6 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #30563



    I’m playing around with reflections on the iPhone 4 (OpenGL ES 2.0) and have just managed to achieve dynamic reflections via rendering to Cube Map (using FBO’s).

    I currently have 6 objects in my scene showing reflections of its 5 neighbors.

    Each object has its own cube map texture and as one can imagine this produces quite a workload.

    One trick to speed things up was simply not to update all the objects reflections every frame, instead I only update one cube map at the time (per frame).

    Rendering a frame looks somewhat like this:

        Choose object to update

        Bind object’s FBO

        Loop all 6 cube map faces

            Transform the ModelViewMatrix

            Loop all 5 otherObjects

                Render otherObject

            End loop

        End loop

        Bind default FBO

        Loop all 6 objects

            Bind CubeMapTexture

            Render object

        End loop

    I do get the expected results, but I’m looking for ways to improve performance!!

    As I mentioned I’m only updating one cube map per frame, boosting fps pretty well.

    Also I’ve reduced the FBO cube map texture size (128×128 -> 64×64, not much difference?).

    Supplying a low-poly version of each model for the rendering to the cube maps.

    Simplifying the shaders used for the objects when rendering to the cube maps.

    (the last two did not affect that much as I’d hoped, but still improvements).

    As of these changes I’ve upped the frame rate from about 13 to 40 fps, so still not quite happy..

    The most recent attempt of optimization (which I just cannot figure out) was to change the texture format of the FBO’s hoping to reduce some texture bandwidth.

    I’m trying to figure out how to use GL_UNSIGNED_SHORT_5_6_5 instead of GL_UNSIGNED_BYTE, but I’ve only managed to get it to work with the latter.

    I’ve google’d the sh*t out of this but I struggle to find any clues..

    From what I can tell I should just be able to change my (currently working) line:

    GLenum textureTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;

    glTexImage2D(textureTarget, 0, GL_RGBA, texSize, texSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);


    glTexImage2D(textureTarget, 0, GL_RGB, texSize, texSize, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0);

    But that just gives me “GL_FRAMEBUFFER_UNSUPPORTED” when checking FBO status, surely I’m missing something..??

    I’ve looked at the OGLES2RenderToTexture sample in the Training Course, which uses the same line (exept the texture target, GL_TEXTURE_2D instead) and runs just fine..?

    Other than the texture target in that line I cannot find any differences in how things are setup.. (apart form the fact that I have multiple FBO’s and so on).

    Anyone with a clue?

    Also, any other tips related to this topic would be greatly appreciated!!

    I’m still a newbie on this stuff, so I may or may not know what I’m talking about.. :):)

    Regards Jonas

    jonkan2011-09-15 21:52:06



    I’ve been at it again and I’m still trying to solve the problem why the texture format UNSIGNED_SHORT_5_6_5 doesn’t work..

    I thought I could add some things.

    GLenum textureTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;

    glTexImage2D(textureTarget, 0, GL_RGB, texSize, texSize, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0);

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, cubeMapTexID[ i ], 0);

    If I do a glGetError() I don’t get any error, however as I mentioned before from glCheckFramebufferStatus(GL_FRAMEBUFFER) I get GL_FRAMEBUFFER_UNSUPPORTED.

    Is it simply not possible to render to a cube map texture with this format??

    //Jonasjonkan2011-09-15 23:06:22

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