Skip to content

Clear color premultiplies alpha #102

@borisblizzard

Description

@borisblizzard

Description:
When setting the LoadAction::clear, the renderer always multiplies the RGB channels with the alpha channel value.

The Issue:
This behavior is undesired in certain scenarios where artifacts show at the borders of rendered shapes. The attached image shows artifacts around the white stroke of the camera button. Usually this issue can be fixed by using a clearColor with the same RGB values as the stroke and an alpha of 0. However, when the multiplication is applied, that clearColor becomes effectively black. In other words: the renderer lacks the option to accept an already premultiplied clearColor.

Image

Proposed Fix:
Introduce a secondary clear mode named LoadAction::clearPremultiplied or a boolean option in RenderContext::FrameDescriptor named premultipliedClearColor (with default false to preserve previously expected behavior).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions