|
@@ -539,69 +539,83 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( ( blending !== CustomBlending ) && ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) ) {
|
|
|
+ if ( blending !== CustomBlending ) {
|
|
|
|
|
|
- if ( blending === AdditiveBlending ) {
|
|
|
+ if ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {
|
|
|
|
|
|
- if ( premultipliedAlpha ) {
|
|
|
+ switch ( blending ) {
|
|
|
|
|
|
- gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
- gl.blendFuncSeparate( gl.ONE, gl.ONE, gl.ONE, gl.ONE );
|
|
|
+ case AdditiveBlending:
|
|
|
|
|
|
- } else {
|
|
|
+ if ( premultipliedAlpha ) {
|
|
|
|
|
|
- gl.blendEquation( gl.FUNC_ADD );
|
|
|
- gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
|
|
|
+ gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
+ gl.blendFuncSeparate( gl.ONE, gl.ONE, gl.ONE, gl.ONE );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- } else if ( blending === SubtractiveBlending ) {
|
|
|
+ gl.blendEquation( gl.FUNC_ADD );
|
|
|
+ gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
|
|
|
|
|
|
- if ( premultipliedAlpha ) {
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
- gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
- gl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
+ case SubtractiveBlending:
|
|
|
|
|
|
- } else {
|
|
|
+ if ( premultipliedAlpha ) {
|
|
|
|
|
|
- gl.blendEquation( gl.FUNC_ADD );
|
|
|
- gl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );
|
|
|
+ gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
+ gl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- } else if ( blending === MultiplyBlending ) {
|
|
|
+ gl.blendEquation( gl.FUNC_ADD );
|
|
|
+ gl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );
|
|
|
|
|
|
- if ( premultipliedAlpha ) {
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
- gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
- gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
|
|
|
+ case MultiplyBlending:
|
|
|
|
|
|
- } else {
|
|
|
+ if ( premultipliedAlpha ) {
|
|
|
|
|
|
- gl.blendEquation( gl.FUNC_ADD );
|
|
|
- gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
|
|
|
+ gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
+ gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- } else {
|
|
|
+ gl.blendEquation( gl.FUNC_ADD );
|
|
|
+ gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
- if ( premultipliedAlpha ) {
|
|
|
+ default:
|
|
|
|
|
|
- gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
- gl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
+ if ( premultipliedAlpha ) {
|
|
|
|
|
|
- } else {
|
|
|
+ gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
+ gl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
|
|
|
- gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
- gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
+ } else {
|
|
|
+
|
|
|
+ gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
|
|
|
+ gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ currentBlendEquation = null;
|
|
|
+ currentBlendSrc = null;
|
|
|
+ currentBlendDst = null;
|
|
|
+ currentBlendEquationAlpha = null;
|
|
|
+ currentBlendSrcAlpha = null;
|
|
|
+ currentBlendDstAlpha = null;
|
|
|
|
|
|
- if ( blending === CustomBlending ) {
|
|
|
+ } else {
|
|
|
|
|
|
blendEquationAlpha = blendEquationAlpha || blendEquation;
|
|
|
blendSrcAlpha = blendSrcAlpha || blendSrc;
|
|
@@ -627,15 +641,6 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- currentBlendEquation = null;
|
|
|
- currentBlendSrc = null;
|
|
|
- currentBlendDst = null;
|
|
|
- currentBlendEquationAlpha = null;
|
|
|
- currentBlendSrcAlpha = null;
|
|
|
- currentBlendDstAlpha = null;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
currentBlending = blending;
|