mosra / magnum

Lightweight and modular C++11 graphics middleware for games and data visualization
https://magnum.graphics/
Other
4.82k stars 438 forks source link

sRGB-related improvements #125

Open mosra opened 9 years ago

mosra commented 9 years ago

sRGB/S3TC

After reading The sRGB learning curve (great article, by the way) I was investigating sRGB support in OpenGL and found out that the old EXT_texture_sRGB extension (part of GL 2.1) had an interaction with EXT_texture_compression_s3tc and provided additional sRGB/DXT compression formats. It might be a good idea to provide these in the TextureFormat and CompressedPixelFormat enums:

    COMPRESSED_SRGB_S3TC_DXT1_EXT                  0x8C4C
    COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT            0x8C4D
    COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT            0x8C4E
    COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT            0x8C4F

OpenGL ES is a bit different. The EXT_sRGB ES extension says the following and the S3TC/SRGB support is then added by NV_sRGB_formats (ES2+).

3) Should we allow the SRGB_*_S3TC_DXT* or any of the other COMPRESSED
formats if the implementation supports any of those formats?

No since all hardware doesn't support this.  It can be added as a separate
extension if needed.

No such thing in WebGL, sadly. WebGL: WEBGL_compressed_texture_s3tc_srgb

S3TC/SRGB support in DDS importer

sRGB-related features

sRGB-related extensions

sRGB conversion utilities

The idea with sRGB is that it only makes sense to do all operations (filtering, interpolating, ...) in linear and use sRGB only as a "compression format" and never do anything with it except for converting from and back to it. Thus it seems to me like it would make sense to have some conversion functions on Math::Color: assuming everything stored in that class is linear and provide sRGB conversion functions that take or return "untyped" Math::Vector3. And, similarly as OpenGL does it, treat alpha channel always as linear (thus copying it without conversion).

Correct sRGB usage (in examples and elsewhere)

Questionable

mosra commented 9 years ago

Some (scary!) information about colorspaces in DDS files: http://stackoverflow.com/questions/13491131/what-are-the-exact-color-spaces-of-dxgi-formats

mosra commented 7 years ago

sRGB support in Color[34] classes done in 2b97e5336022841e1ff4d122d5acea4b10dc276f.

mosra commented 6 years ago

Just discovered that WebGL has WEBGL_compressed_texture_s3tc_srgb.

mosra commented 6 years ago

Added http://www.ericbrasseur.org/gamma.html to the list, great set of test images. Chrome on my HiDPI screen is apparently not doing the right thing, it seems.

Squareys commented 6 years ago

Ha! Chome on Windows 10 without HiDPI fails the test also 😆

mosra commented 6 years ago

Nah, actually it seems to be doing the correct thing: http://www.ericbrasseur.org/gamma_dalai_lama.html

mosra commented 5 years ago