|
@@ -1,4 +1,5 @@
|
|
|
-import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';
|
|
|
+import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
|
+import { Color } from '../../math/Color.js';
|
|
|
import { Vector4 } from '../../math/Vector4.js';
|
|
|
|
|
|
function WebGLState( gl, extensions, capabilities ) {
|
|
@@ -325,6 +326,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
let currentBlendEquationAlpha = null;
|
|
|
let currentBlendSrcAlpha = null;
|
|
|
let currentBlendDstAlpha = null;
|
|
|
+ let currentBlendColor = new Color( 0, 0, 0 );
|
|
|
+ let currentBlendAlpha = 0;
|
|
|
let currentPremultipledAlpha = false;
|
|
|
|
|
|
let currentFlipSided = null;
|
|
@@ -600,10 +603,14 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
|
|
|
[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
|
|
|
[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
|
|
|
- [ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA
|
|
|
+ [ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
|
|
|
+ [ ConstantColorFactor ]: gl.CONSTANT_COLOR,
|
|
|
+ [ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
|
|
|
+ [ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
|
|
|
+ [ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
|
|
|
};
|
|
|
|
|
|
- function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
|
|
|
+ function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
|
|
|
|
|
|
if ( blending === NoBlending ) {
|
|
|
|
|
@@ -696,6 +703,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
currentBlendDst = null;
|
|
|
currentBlendSrcAlpha = null;
|
|
|
currentBlendDstAlpha = null;
|
|
|
+ currentBlendColor.set( 0, 0, 0 );
|
|
|
+ currentBlendAlpha = 0;
|
|
|
|
|
|
currentBlending = blending;
|
|
|
currentPremultipledAlpha = premultipliedAlpha;
|
|
@@ -732,6 +741,15 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
|
|
|
+
|
|
|
+ gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
|
|
|
+
|
|
|
+ currentBlendColor.copy( blendColor );
|
|
|
+ currentBlendAlpha = blendAlpha;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
currentBlending = blending;
|
|
|
currentPremultipledAlpha = false;
|
|
|
|
|
@@ -750,7 +768,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
|
|
|
( material.blending === NormalBlending && material.transparent === false )
|
|
|
? setBlending( NoBlending )
|
|
|
- : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );
|
|
|
+ : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
|
|
|
|
|
|
depthBuffer.setFunc( material.depthFunc );
|
|
|
depthBuffer.setTest( material.depthTest );
|
|
@@ -1174,6 +1192,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
gl.blendEquation( gl.FUNC_ADD );
|
|
|
gl.blendFunc( gl.ONE, gl.ZERO );
|
|
|
gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
|
+ gl.blendColor( 0, 0, 0, 0 );
|
|
|
|
|
|
gl.colorMask( true, true, true, true );
|
|
|
gl.clearColor( 0, 0, 0, 0 );
|
|
@@ -1231,6 +1250,8 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
currentBlendEquationAlpha = null;
|
|
|
currentBlendSrcAlpha = null;
|
|
|
currentBlendDstAlpha = null;
|
|
|
+ currentBlendColor = new Color( 0, 0, 0 );
|
|
|
+ currentBlendAlpha = 0;
|
|
|
currentPremultipledAlpha = false;
|
|
|
|
|
|
currentFlipSided = null;
|