Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color space design #1035

Open
bvssvni opened this issue Feb 25, 2016 · 3 comments
Open

Color space design #1035

bvssvni opened this issue Feb 25, 2016 · 3 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented Feb 25, 2016

Piston-Graphics uses colors in sRGB color space. For more information on sRGB, see PistonDevelopers/piston#1014.

There are two major candidates for color space design in a 2D graphics library:

  • Linear sRGB color space (mathematical nice properties)
  • sRGB color space (integrates well with image editors, html color codes, etc.)

At the moment, Piston-Graphics uses sRGB to maintain backward compatibility with what most people think of as colors.

This means that graphics backends that take uniform or vertex color parameters in linear color space for shaders must convert from sRGB to linear.

  • When sRGB is enabled in OpenGL, the shader works in linear color space and converts automatically from the color format of a texture
  • When sRGB is disabled, the color space in the shader depends on the color space you use
@kryptan
Copy link

kryptan commented Feb 11, 2017

Linear color space

I suggest to call it linear sRGB color space. There are many different linear color spaces which can be converted between each other using matrix multiplication. Calling it simply linear is thus confusing. Linear sRGB is the color space with the same primaries and white point as sRGB but identity transfer function.

@kryptan
Copy link

kryptan commented Feb 11, 2017

The world is slowly moving to color spaces larger than sRGB.

There are mainly two things:

  1. High dynamic range (HDR) - mainly colors brighter than nominal white.
  2. Wide color gamut (WCG) - colors outside the sRGB gamut. Standards use the Rec. 2020 color space but current monitors can only display some subset of it.

Modern GPUs already support those and monitors are slowly starting to appear, although they are pricey at this point but this probably will change over time.

Supporting these things when using linear sRGB is easier as you just need to allow values greater than one for HDR and negative values for WCG.

Currently this is probably more relevant for high-end 3D games and video output but still.

@bvssvni
Copy link
Member Author

bvssvni commented Feb 11, 2017

Updated top comment.

Is it possible to support HDR and WCG with normal sRGB?

We are using floats for colors, but they are defined to use normal sRGB in the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants