Skip to content

Suggestion: Add "alpha" to Color instance? #32742

@gkjohnson

Description

@gkjohnson

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:

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.

cc @donmccurdy @WestLangley

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions