[osg-users] Problems with assumeSizedInternalFormat

Paul Zimmons pzimmons at mak.com
Fri Sep 2 14:21:53 PDT 2016

Hello everybody,

    When using a terrapage terrain with RGB textures for low LOD tiles, I noticed that low LOD tiles looked darker than the other tiles on the terrain. Why?

    The RGB textures from terrapage includes mipmap data which is manually added to the image in the function txp::getTemplateTexture. The mip map data offsets are set with setMipmapLevels. Then setImage is used to put it on an osg::Texture2D.

     In Texture.cpp, the mip map data is conveyed to OpenGL with applyTexImage2D_load which, before calling glTexSubImage2D, calls a function: assumeSizedInternalFormat.

     assumeSizedInternalFormat iterates over sizedInternalFormats looking for sizedInternalFormats which match the internalFormat (GL_RGB) and type (GL_UNSIGNED_BYTE). And returns the FIRST match. This is a problem because multiple sizedInternalFormats match. In particular in this case, GL_SRGB8, GL_RGB8, GL_RGB565 all match the search criteria.

     In the version of OSG I was using, the RGB texture was GL_RGB8 format but the format returned byassumeSizedInternalFormat for the mipmaps was GL_SRGB8 making everything darker. 

     I noticed in the latest OSG, the orders have changed. However, this also does not solve the problem since if I want GL_SRGB8, I would get GL_RGB8 and the texture mip maps would appear too bright.

     Other formats will have this issue as well (ex. GL_RGBA4 and GL_RGBA8, GL_RGB16F_ARG and GL_RGB32F_ARB).

     I believe the approach in this function is not quite adequate, so I am interested in thoughts about how to fix this issue.

Thank you!


Read this topic online here:

More information about the osg-users mailing list