pex-gl / pex-context

Modern WebGL state wrapper for PEX: allocate GPU resources (textures, buffers), setup state pipelines and passes, and combine them into commands.
http://pex-gl.github.io/pex-context/
MIT License
160 stars 12 forks source link

Alpha to coverage #53

Open vorg opened 5 years ago

vorg commented 5 years ago

@dmnsgn Created this pull request so we can track progress.

Comments so far:

Scope

Is this about antialiasing or A2C? Or is A2C form of antialiasing?

Asset sources

We need to provide sources for the used textures and if unknown or license doesn't allow redistribution we should make our own

A2C vs Alpha Test

It's unnecessary as it actually stops A2C gradient half way and looks wrong. Although this tweet suggest otherwise and mattdesl has dynamically adjusted cutout value of 0.4 https://twitter.com/mattdesl/status/900009193649975296?lang=en

Maybe alpha test / cutoff is for performance reasons?

screenshot 2018-10-10 at 22 32 46

AlphaToCoverage vs Sample Coverage

AlphaToCoverage is just a toggle and not related (?) to gl.sampleCoverage which takes 0..1 value but it has to be also enabled separately with gl.enable(gl.SAMPLE_COVERAGE). Not sure what is it doing or how is it supposed to be used as it clamps max alpha and therefore causes image to "fade out" via dithering.

screenshot 2018-10-10 at 22 52 44

Better assets

Brush asset should be completely white and only have alpha channel

screenshot 2018-10-10 at 22 37 50

API

Any suggestions for the interface? E.g. regl/API.md#sample-coverage

 sample: {
    enable: true,
    alpha: false,
    coverage: {
      value: 1,
      invert: false
    }
  }

Given that sampleCoverage is different from alphaToCoverage i suggest

ctx.pipeline({
  alphaToCoverage: true
})