Webgl / clarify premultiplied alpha handling
By default, alpha premultiplying should be done by the initial rendering (eg quads) and not the final post processing pass. The default post processing pass expects premultiplied color values and will not do this operation itself.
This commit is contained in:
@@ -28,7 +28,6 @@ const DEFAULT_FRAGMENT_SHADER = `
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_image, v_texCoord);
|
||||
gl_FragColor.rgb *= gl_FragColor.a;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -59,6 +58,9 @@ const DEFAULT_FRAGMENT_SHADER = `
|
||||
* a pixel which is 100% red with an opacity of 50% must have a color of (r=0.5, g=0, b=0, a=0.5).
|
||||
* Failing to provide pixel colors with premultiplied alpha will result in render anomalies.
|
||||
*
|
||||
* The default post-processing pass does *not* multiply color values with alpha value, it expects color values to be
|
||||
* premultiplied.
|
||||
*
|
||||
* Default shaders are shown hereafter:
|
||||
*
|
||||
* * Vertex shader:
|
||||
@@ -91,7 +93,6 @@ const DEFAULT_FRAGMENT_SHADER = `
|
||||
*
|
||||
* void main() {
|
||||
* gl_FragColor = texture2D(u_image, v_texCoord);
|
||||
* gl_FragColor.rgb *= gl_FragColor.a;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user