Un-premultiply extracted drawables
This commit is contained in:
@@ -1124,7 +1124,8 @@ class RenderWebGL extends EventEmitter {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
try {
|
||||
gl.disable(gl.BLEND);
|
||||
this._drawThese([drawableID], ShaderManager.DRAW_MODE.default, projection,
|
||||
// ImageData objects store alpha un-premultiplied, so draw with the `straightAlpha` draw mode.
|
||||
this._drawThese([drawableID], ShaderManager.DRAW_MODE.straightAlpha, projection,
|
||||
{effectMask: ~ShaderManager.EFFECT_INFO.ghost.mask});
|
||||
} finally {
|
||||
gl.enable(gl.BLEND);
|
||||
|
||||
@@ -158,6 +158,11 @@ ShaderManager.DRAW_MODE = {
|
||||
*/
|
||||
default: 'default',
|
||||
|
||||
/**
|
||||
* Un-premultiply alpha. Useful for reading pixels from GL into an ImageData object.
|
||||
*/
|
||||
straightAlpha: 'straightAlpha',
|
||||
|
||||
/**
|
||||
* Draw a silhouette using a solid color.
|
||||
*/
|
||||
|
||||
@@ -210,6 +210,11 @@ void main()
|
||||
#endif // DRAW_MODE_colorMask
|
||||
#endif // DRAW_MODE_silhouette
|
||||
|
||||
#ifdef DRAW_MODE_straightAlpha
|
||||
// Un-premultiply alpha.
|
||||
gl_FragColor.rgb /= gl_FragColor.a + epsilon;
|
||||
#endif
|
||||
|
||||
#else // DRAW_MODE_lineSample
|
||||
gl_FragColor = u_lineColor * clamp(
|
||||
// Scale the capScale a little to have an aliased region.
|
||||
|
||||
Reference in New Issue
Block a user