-
Notifications
You must be signed in to change notification settings - Fork 61
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
Distinction between Srgb
encoding and Linear<Srgb>
encoding?
#133
Comments
The biggest update to account for here was the distinction between `RgbSpace`s. Nannou now uses the `Srgb` standard encoding as a default throughout the crate which should more accurately represents nannou's provided set of named colors (nannou-org#72) and likely close match users expectations of the behaviour. Closes nannou-org#72. Closes nannou-org#345. TODO: - [ ] Decide whether or not to re-add the `Rgb` and `Rgba` types to the `color` module? Or should we encourage use of the `Srgb` and `Srgba` types instead for clarity? - [ ] Clarify whether we should be useing `Srgb` or `Linear<Srgb>` RGB encoding for nannou's default draw API. I've opened up Ogeon/palette#133 to help clarify my understanding on this. - [ ] Add a suite of super simple constructor functions to the color module (e.g. `hsl`, `hsla`, `rgb`, `rgba`, etc) that produce color types that are easily compatible with nannou's `Draw` API. - [ ] Decide if we should keep the Tango based `named` colors provided by nannou (see [here][1]) or only use those provided [by palette][2]. Alternatively we could keep both, but this would mean removing the glob palette import to fix nannou-org#345 and re-exporting `palette`'s named colors into our own named module. - [ ] Decide what the most convenient type is for `named` colors. We should probably change them to the same type as `palette`'s named colors, but also ensure that these can be conveniently used within all areas of the `Draw` API. - [ ] Create a `colors.rs` example that demonstrates all named colors within the crate. Ensure that these colors visibly match their references. cc @SjorsVanGelderen. [1]: /~https://github.com/nannou-org/nannou/blob/master/src/color.rs#L12 [2]: https://docs.rs/palette/0.4.1/palette/named/index.html
The biggest update to account for here was the distinction between `RgbSpace`s. Nannou now uses the `Srgb` standard encoding as a default throughout the crate which should more accurately represents nannou's provided set of named colors (nannou-org#72) and likely close match users expectations of the behaviour. Closes nannou-org#72. Closes nannou-org#345. TODO: - [ ] Decide whether or not to re-add the `Rgb` and `Rgba` types to the `color` module? Or should we encourage use of the `Srgb` and `Srgba` types instead for clarity? - [ ] Clarify whether we should be useing `Srgb` or `Linear<Srgb>` RGB encoding for nannou's default draw API. I've opened up Ogeon/palette#133 to help clarify my understanding on this. - [ ] Add a suite of super simple constructor functions to the color module (e.g. `hsl`, `hsla`, `rgb`, `rgba`, etc) that produce color types that are easily compatible with nannou's `Draw` API. - [ ] Decide if we should keep the Tango based `named` colors provided by nannou (see [here][1]) or only use those provided [by palette][2]. Alternatively we could keep both, but this would mean removing the glob palette import to fix nannou-org#345 and re-exporting `palette`'s named colors into our own named module. - [ ] Decide what the most convenient type is for `named` colors. We should probably change them to the same type as `palette`'s named colors, but also ensure that these can be conveniently used within all areas of the `Draw` API. - [ ] Create a `colors.rs` example that demonstrates all named colors within the crate. Ensure that these colors visibly match their references. cc @SjorsVanGelderen. [1]: /~https://github.com/nannou-org/nannou/blob/master/src/color.rs#L12 [2]: https://docs.rs/palette/0.4.1/palette/named/index.html
Hi! Excellent question and something that should be clarified in the documentation at some point. The short version is that sRGB is basically a storage format, where the values does not map 1:1 with the intensity they represent. So 50% is not encoded as 0.5 in sRGB, and this will affect blending operations among other things. Linear RGB is the "normal" scale, where 50% brightness is represented by 0.5, and the same goes for the rest of the scale. It's just straight intensity values (as far as that's true for RGB in general). sRGB stems from how old CRT displays work and does also have the benefit of a higher resolution among the darker colors. That reduces the banding effect because it also matches how we see colors. It works as a type of compression. This video explains it in a short and nice way: https://youtu.be/LKnqECcg6Gw I would recommend a workflow or data flow where the color is converted to linear space as soon as possible and stays like that internally. It can then be converted back when it's outputted to some media that want sRGB (image, display, etc.). I.e. a "linear workflow". |
Thanks a lot for the valuable insight, I'm glad that I asked! Is it possible for there to be other kinds of I'll checkout this video tonight, I love minutephysics :) |
Yes! RGB has two other parameters, beside the "transfer function" (linear v.s. nonlinear):
There are plenty of RGB standards with different values for these, but sRGB is the most common. It's all a bit of a rabbit hole and you don't have to go down there unless you want to support working with a wider gamut (wider range of perceivable colors) or doing more advanced color adaptions. |
So |
Thanks, that clears things up for me! I'm happy for this to be closed, but will leave it open in case you'd like the reminder for the addition to the docs :) |
It can stay open for now. 🙂 Feel free to come back and ask more if there are any more road blocks! |
Oh I should probably clarify that any shader code should also be considered being within the linear part of the pipeline, so don't convert to sRGB until just before it ends up on the monitor for the best results. That is unless the shader itself expect sRGB as input, or unless the graphics backed is set to convert it for you. I don't know how your current pipeline looks, so that may already be taken care of, but I'm mentioning it just in case... |
The biggest update to account for here was the distinction between `RgbSpace`s. Nannou now uses the `Srgb` standard encoding as a default throughout the crate which should more accurately represents nannou's provided set of named colors (nannou-org#72) and likely close match users expectations of the behaviour. Closes nannou-org#72. Closes nannou-org#345. TODO: - [ ] Decide whether or not to re-add the `Rgb` and `Rgba` types to the `color` module? Or should we encourage use of the `Srgb` and `Srgba` types instead for clarity? - [ ] Clarify whether we should be useing `Srgb` or `Linear<Srgb>` RGB encoding for nannou's default draw API. I've opened up Ogeon/palette#133 to help clarify my understanding on this. - [ ] Add a suite of super simple constructor functions to the color module (e.g. `hsl`, `hsla`, `rgb`, `rgba`, etc) that produce color types that are easily compatible with nannou's `Draw` API. - [ ] Decide if we should keep the Tango based `named` colors provided by nannou (see [here][1]) or only use those provided [by palette][2]. Alternatively we could keep both, but this would mean removing the glob palette import to fix nannou-org#345 and re-exporting `palette`'s named colors into our own named module. - [ ] Decide what the most convenient type is for `named` colors. We should probably change them to the same type as `palette`'s named colors, but also ensure that these can be conveniently used within all areas of the `Draw` API. - [ ] Create a `colors.rs` example that demonstrates all named colors within the crate. Ensure that these colors visibly match their references. cc @SjorsVanGelderen. [1]: /~https://github.com/nannou-org/nannou/blob/master/src/color.rs#L12 [2]: https://docs.rs/palette/0.4.1/palette/named/index.html
The biggest update to account for here was the distinction between `RgbSpace`s. Nannou now uses the `Srgb` standard encoding as a default throughout the crate which should more accurately represents nannou's provided set of named colors (nannou-org#72) and likely close match users expectations of the behaviour. Closes nannou-org#72. Closes nannou-org#345. TODO: - [ ] Decide whether or not to re-add the `Rgb` and `Rgba` types to the `color` module? Or should we encourage use of the `Srgb` and `Srgba` types instead for clarity? - [ ] Clarify whether we should be useing `Srgb` or `Linear<Srgb>` RGB encoding for nannou's default draw API. I've opened up Ogeon/palette#133 to help clarify my understanding on this. - [ ] Add a suite of super simple constructor functions to the color module (e.g. `hsl`, `hsla`, `rgb`, `rgba`, etc) that produce color types that are easily compatible with nannou's `Draw` API. - [ ] Decide if we should keep the Tango based `named` colors provided by nannou (see [here][1]) or only use those provided [by palette][2]. Alternatively we could keep both, but this would mean removing the glob palette import to fix nannou-org#345 and re-exporting `palette`'s named colors into our own named module. - [ ] Decide what the most convenient type is for `named` colors. We should probably change them to the same type as `palette`'s named colors, but also ensure that these can be conveniently used within all areas of the `Draw` API. - [ ] Create a `colors.rs` example that demonstrates all named colors within the crate. Ensure that these colors visibly match their references. cc @SjorsVanGelderen. [1]: /~https://github.com/nannou-org/nannou/blob/master/src/color.rs#L12 [2]: https://docs.rs/palette/0.4.1/palette/named/index.html
Hi @Ogeon! I'm (finally) updating nannou from 0.2 to 0.4 and I'm a little confused about the distinction between the
Srgb
andLinear<Srgb>
encodings.I'd always thought that sRGB and Linear were two distinct encodings. Specifically, I thought that
Linear
was a direct mapping to the hardware output, whereas sRGB was a mapping that is friendlier to the perceivable colour range. What does it mean to haveLinear<Srgb>
?Sorry for the ordinary question! Feel free to point me elsewhere if there's somewhere I can read up properly on this 🙏
The text was updated successfully, but these errors were encountered: