Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it that straightforward? Does it depend on the color type? Is alpha ignored? How can I get the total brightness from each channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know; I was just following the comments in the issue. @fintelia or @superdump, could you comment on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First the color gets converted to linear sRGB (if necessary) and scaled by the brightness:
bevy/crates/bevy_pbr/src/render/light.rs
Lines 985 to 986 in 4da11fd
Then the alpha channel gets completely ignored via a swizzle and the RGB channels are used for rendering calculations:
bevy/crates/bevy_pbr/src/render/pbr_ambient.wgsl
Line 28 in 4da11fd
Interpreting the meaning of the three values in the RGB channels is a much deeper rabbit hole. My non-expert understanding is that a value like (100.0, 100.0, 100.0) corresponds to a total light intensity of 100 cd/m^2 divided up as 21 cd/m^2 of red light, 72 cd/m^2 of green light, and 7 cd/m^2 of blue light. Where the colors precise meanings of "red light", "green light", and "blue light" are given by the sRGB spec and the relative weights also come from that same spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on its usage in prepare_lights, the ambient light is always converted to
LinearRgba
(so colour space does not matter), and the colour passed to the GPU is this colour scaled by brightness.So, we could either say
Color
is unitless (a scalar) andbrightness
is incd/m^2
, or the reverse. I think we want to sayColor
is unitless because it conceptually makes more sense thatbrightness
is the intensity value (candela/square-metre).