Skip to content

Alpha to Coverage Support #12438

@mattdesl

Description

@mattdesl
Feature: Support Alpha To Coverage

It would be nice to support a flag for Alpha to Coverage. This feature has existed in WebGL contexts for a while, however, it seems hardly used in practice.

It can be used to create really crisp alpha cutouts with MSAA-enabled contexts.

When enabled, you no longer need to specify alphaTest or perform a discard in the fragment shader, you simply output the frag alpha and the GL context will handle cutouts. You can read more about it here, including some tricks to make things even smoother.

// enable alpha to coverage with current ThreeJS renderer
const gl = renderer.getContext();
gl.enable(gl.SAMPLE_ALPHA_TO_COVERAGE);

This feature assumes MSAA is enabled and supported (i.e. may not work in external monitors).

Here is an example wireframe shader using alpha to coverage:
https://mattdesl.github.io/webgl-wireframes/app/
screenshot 64

Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions