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

Add color space blend and alpha notes to Color documentation #104410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aaronfranke
Copy link
Member

I discussed color spaces and blending with @allenwp in person at GDC and he mentioned these things, which I think should be explicitly stated in the documentation.

@beicause
Copy link
Contributor

beicause commented Mar 21, 2025

I have a question: doesn't the sRGB encoding ignore the alpha channel by nature? I don't heard of the difference of alpha between sRGB space and linear space and non-linear alpha encoding.

VK_FORMAT_R8G8B8A8_SRGB specifies a four-component, 32-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, an 8-bit B component stored with sRGB nonlinear encoding in byte 2, and an 8-bit A component in byte 3.

Vulkan VK_FORMAT_R8G8B8A8_SRGB doesn't use non-linear alpha, too. I doubt if non-linear alpha has any use cases.

@allenwp
Copy link
Contributor

allenwp commented Mar 21, 2025

I have a question: doesn't the sRGB encoding ignore the alpha channel by nature? I don't heard of the difference of alpha between sRGB space and linear space and non-linear alpha encoding.

VK_FORMAT_R8G8B8A8_SRGB specifies a four-component, 32-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, an 8-bit B component stored with sRGB nonlinear encoding in byte 2, and an 8-bit A component in byte 3.

Vulkan VK_FORMAT_R8G8B8A8_SRGB doesn't use non-linear alpha, too. I doubt if non-linear alpha has any use cases.

You are correct and this PR aims to explicitly state exactly what you described in your comment for those who are unaware of this.

@beicause
Copy link
Contributor

Since there is no other case about the alpha channel, why is it necessary to explicitly state it?

Copy link
Contributor

@allenwp allenwp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alpha channel often does not exist in the concept of a [color] space (at least in the parts of colorimetry where nonlinear/linear sRGB are being discussed), so I believe it will be less confusing to use the term "linear encoding" than "linear space" when describing how the alpha channel is stored.

@allenwp
Copy link
Contributor

allenwp commented Mar 21, 2025

Since there is no other case about the alpha channel, why is it necessary to explicitly state it?

Both Aaron and I were uncertain about what encoding was common or expected for the alpha channel of color data, especially because this Color data structure can hold either linear or nonlinear encoding for the RGB channels. Since both of us had this uncertainty, we expect that other users may similarly be unsure. Adding this explicit statement will help others have clarity on this point.

@allenwp
Copy link
Contributor

allenwp commented Mar 21, 2025

Since we're here, it might be also good to add something like this to the class description:

Color data may be stored in nonlinear sRGB encoding or linear RGB encoding. Use srgb_to_linear and linear_to_srgb to convert between these two color spaces.

@allenwp
Copy link
Contributor

allenwp commented Mar 22, 2025

Since we're here, it might be also good to add something like this to the class description:

Color data may be stored in nonlinear sRGB encoding or linear RGB encoding. Use srgb_to_linear and linear_to_srgb to convert between these two color spaces.

After thinking more about it, this text might make a problem with the ambiguity of Color encoding worse. Maybe the following text would be better?

Red, green, and blue values of Color use nonlinear sRGB encoding within Godot, unless stated otherwise by documentation.

If this is ever untrue a documentation issue should be opened.

Thoughts?

(I can make this sort of change a separate PR if you'd prefer.)

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

Successfully merging this pull request may close these issues.

5 participants