Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/misc_exporter_usdz.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

const geometry = new THREE.PlaneGeometry();
const material = new THREE.MeshBasicMaterial( {
map: shadowTexture, blending: THREE.MultiplyBlending, toneMapped: false
map: shadowTexture, blending: THREE.MultiplyBlending, toneMapped: false, premultipliedAlpha: true
} );

const mesh = new THREE.Mesh( geometry, material );
Expand Down
2 changes: 2 additions & 0 deletions examples/webgl_materials_blending.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
material.transparent = true;
material.blending = blending.constant;

material.premultipliedAlpha = true;

const x = ( i - blendings.length / 2 ) * 110;
const z = 0;

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_car.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry( 0.655 * 4, 1.3 * 4 ),
new THREE.MeshBasicMaterial( {
map: shadow, blending: THREE.MultiplyBlending, toneMapped: false, transparent: true
map: shadow, blending: THREE.MultiplyBlending, toneMapped: false, transparent: true, premultipliedAlpha: true
} )
);
mesh.rotation.x = - Math.PI / 2;
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_envmaps_groundprojected.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry( 0.655 * 4, 1.3 * 4 ),
new THREE.MeshBasicMaterial( {
map: shadow, blending: THREE.MultiplyBlending, toneMapped: false, transparent: true
map: shadow, blending: THREE.MultiplyBlending, toneMapped: false, transparent: true, premultipliedAlpha: true
} )
);
mesh.rotation.x = - Math.PI / 2;
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/webgl-fallback/utils/WebGLState.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class WebGLState {
break;

case MultiplyBlending:
gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
break;

default:
Expand All @@ -357,15 +357,15 @@ class WebGLState {
break;

case AdditiveBlending:
gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
break;

case SubtractiveBlending:
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
console.error( 'THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
break;

case MultiplyBlending:
gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
console.error( 'THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
break;

default:
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/webgl/WebGLState.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ function WebGLState( gl, extensions ) {
break;

case MultiplyBlending:
gl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );
gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
break;

default:
Expand All @@ -685,15 +685,15 @@ function WebGLState( gl, extensions ) {
break;

case AdditiveBlending:
gl.blendFunc( gl.SRC_ALPHA, gl.ONE );
gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
break;

case SubtractiveBlending:
gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
console.error( 'THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
break;

case MultiplyBlending:
gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
console.error( 'THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
break;

default:
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/webgpu/utils/WebGPUPipelineUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class WebGPUPipelineUtils {
break;

case MultiplyBlending:
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.SrcAlpha );
setBlend( GPUBlendFactor.Dst, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.Zero, GPUBlendFactor.One );
break;

}
Expand All @@ -403,15 +403,15 @@ class WebGPUPipelineUtils {
break;

case AdditiveBlending:
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.SrcAlpha, GPUBlendFactor.One );
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
break;

case SubtractiveBlending:
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
console.error( 'THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true' );
break;

case MultiplyBlending:
setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.Src );
console.error( 'THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true' );
break;

}
Expand Down