Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does glGenerateMipmap perform its averaging in linear space for sRGB textures?

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?

like image 956
Niriel Avatar asked Mar 12 '14 10:03

Niriel


1 Answers

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.

like image 146
datenwolf Avatar answered Oct 27 '22 09:10

datenwolf