-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Description
Description
Issue #32725 made me wonder why "alpha" isn't included in the "Color" class definition. It's a little odd to have to bookkeep a color with alpha as a "Vector4" in cases where 4-tuple color buffers or uniforms are being worked with. It would enable alignment with what existing textures classes and shaders model as a "pixel" color (RGBA), as well as most other engines:
- CSS Color Module 4 allows for specifying alpha even with hex notation, now
- Unity includes a "Color.a" component
- Unreal engine includes "color" and "color with alpha" structs ("color with alpha" is a struct with a "color" member and "alpha" member)
- Babylon supports a Color3 and Color4 class
- PlayCanvas supports "alpha" in its Color class
It seems like Blender may have a couple different representations, some without alpha and some with, depending on where "Color" is being used? It's not clear to me. But at least from the above it looks like three.js is the only realtime engine that doesn't have a "Color" class with an "alpha" component available.
Solution
Add "alpha" to the Color instance. The Material.opacity field can be kept for backwards compatibility. I don't think this will have any breaking change implications:
- alpha will default to 1
- additional functions to handle alpha can be added - though it can be ignored or reset to 1 for any RGB-specific functions.
- Materials can multiply both "color.a" and "opacity" together.
Alternatives
No changes
Additional context
No response