Parcourir la source

Renderers: Add warnOnce calls to incorrect blending modes.

Mr.doob il y a 4 mois
Parent
commit
74e50e813d

+ 3 - 1
src/renderers/webgl-fallback/utils/WebGLState.js

@@ -7,7 +7,7 @@ import {
 	NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth
 } from '../../../constants.js';
 import { Vector4 } from '../../../math/Vector4.js';
-import { error } from '../../../utils.js';
+import { error, warnOnce } from '../../../utils.js';
 
 let equationToGL, factorToGL;
 
@@ -377,10 +377,12 @@ class WebGLState {
 							break;
 
 						case SubtractiveBlending:
+							warnOnce( 'WebGLState: SubtractiveBlending works best with material.premultipliedAlpha = true.' );
 							gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
 							break;
 
 						case MultiplyBlending:
+							warnOnce( 'WebGLState: MultiplyBlending works best with material.premultipliedAlpha = true.' );
 							gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
 							break;
 

+ 3 - 1
src/renderers/webgl/WebGLState.js

@@ -1,7 +1,7 @@
 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';
-import { error } from '../../utils.js';
+import { error, warnOnce } from '../../utils.js';
 
 const reversedFuncs = {
 	[ NeverDepth ]: AlwaysDepth,
@@ -690,10 +690,12 @@ function WebGLState( gl, extensions ) {
 							break;
 
 						case SubtractiveBlending:
+							warnOnce( 'WebGLState: SubtractiveBlending works best with material.premultipliedAlpha = true.' );
 							gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
 							break;
 
 						case MultiplyBlending:
+							warnOnce( 'WebGLState: MultiplyBlending works best with material.premultipliedAlpha = true.' );
 							gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
 							break;
 

+ 3 - 1
src/renderers/webgpu/utils/WebGPUPipelineUtils.js

@@ -15,7 +15,7 @@ import {
 	NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
 } from '../../../constants.js';
 
-import { error } from '../../../utils.js';
+import { error, warnOnce } from '../../../utils.js';
 
 /**
  * A WebGPU backend utility module for managing pipelines.
@@ -448,10 +448,12 @@ class WebGPUPipelineUtils {
 						break;
 
 					case SubtractiveBlending:
+						warnOnce( 'WebGPURenderer: SubtractiveBlending works best with material.premultipliedAlpha = true.' );
 						setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
 						break;
 
 					case MultiplyBlending:
+						warnOnce( 'WebGPURenderer: MultiplyBlending works best with material.premultipliedAlpha = true.' );
 						setBlend( GPUBlendFactor.Dst, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.Zero, GPUBlendFactor.One );
 						break;
 

粤ICP备19079148号