6

The OpenGL 3.3 specification does not seem to ask that the mipmap generation be done in linear space. All I can find is the following:

The internal formats of the derived mipmap arrays all match those of the levelbase array, and the dimensions of the derived arrays follow the requirements described in section 3.8.14. The contents of the derived arrays are computed by repeated, filtered reduction of the levelbase array. For one- and two-dimensional array textures, each layer is filtered independently. No particular filter algorithm is required, though a box filter is recommended as the default filter.

I understand that the result of calling glGenerateMipMap is in sRGB if the original image is in sRGB and I have no problem with that. But what happens in-between? Surely we do not want to average colors that are on a log scale. Is that implementation-specific?

Niriel
  • 2,605
  • 3
  • 29
  • 36
  • 1
    I'd just like to point out that my AMD Radeon HD 7950 card seems not to do this in linear space. It may be a driver issue. To be on the safe side, I generate my mipmaps on the CPU for sRGB textures. – rdb Oct 08 '14 at 18:44

1 Answers1

8

The relevant answer can be found in the OpenGL specification section 3.8.17:

3.8.17 sRGB Texture Color Conversion

If the currently bound texture’s internal format is one of SRGB,SRGB8,SRGB_ALPHA, SRGB8_ALPHA8, COMPRESSED_SRGB, or COMPRESSED_SRGB_ALPHA, the red, green, and blue components are converted from an sRGB color space to a linear color space as part of filtering described in sections 3.8.11 and 3.8.12. Any alpha component is left unchanged. Ideally, implementations should perform this color conversion on each sample prior to filtering but implementations are allowed

Mipmap generation is described in section 3.8.11 and hence is subject to color space linearization.

datenwolf
  • 159,371
  • 13
  • 185
  • 298