|
|
@@ -1723,7 +1723,8 @@ ColorManagement.define( {
|
|
|
toXYZ: LINEAR_REC709_TO_XYZ,
|
|
|
fromXYZ: XYZ_TO_LINEAR_REC709,
|
|
|
luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
|
|
|
- workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace }
|
|
|
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
|
|
|
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
|
|
|
},
|
|
|
|
|
|
[ SRGBColorSpace ]: {
|
|
|
@@ -59100,10 +59101,9 @@ const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
|
|
|
|
} );
|
|
|
|
|
|
-const _luminanceCoefficients = /*@__PURE__*/ new Vector3();
|
|
|
const luminance = (
|
|
|
color,
|
|
|
- luminanceCoefficients = vec3( ... ColorManagement.getLuminanceCoefficients( _luminanceCoefficients ) )
|
|
|
+ luminanceCoefficients = vec3( ColorManagement.getLuminanceCoefficients( new Vector3() ) )
|
|
|
) => dot( color, luminanceCoefficients );
|
|
|
|
|
|
const threshold = ( color, threshold ) => mix( vec3( 0.0 ), color, luminance( color ).sub( threshold ).max( 0 ) );
|
|
|
@@ -62175,9 +62175,11 @@ class Textures extends DataMap {
|
|
|
const mipHeight = size.height >> activeMipmapLevel;
|
|
|
|
|
|
let depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];
|
|
|
+ const useDepthTexture = renderTarget.depthBuffer === true || renderTarget.stencilBuffer === true;
|
|
|
+
|
|
|
let textureNeedsUpdate = false;
|
|
|
|
|
|
- if ( depthTexture === undefined ) {
|
|
|
+ if ( depthTexture === undefined && useDepthTexture ) {
|
|
|
|
|
|
depthTexture = new DepthTexture();
|
|
|
depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
|
|
|
@@ -62192,17 +62194,21 @@ class Textures extends DataMap {
|
|
|
if ( renderTargetData.width !== size.width || size.height !== renderTargetData.height ) {
|
|
|
|
|
|
textureNeedsUpdate = true;
|
|
|
- depthTexture.needsUpdate = true;
|
|
|
|
|
|
- depthTexture.image.width = mipWidth;
|
|
|
- depthTexture.image.height = mipHeight;
|
|
|
+ if ( depthTexture ) {
|
|
|
+
|
|
|
+ depthTexture.needsUpdate = true;
|
|
|
+ depthTexture.image.width = mipWidth;
|
|
|
+ depthTexture.image.height = mipHeight;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
renderTargetData.width = size.width;
|
|
|
renderTargetData.height = size.height;
|
|
|
renderTargetData.textures = textures;
|
|
|
- renderTargetData.depthTexture = depthTexture;
|
|
|
+ renderTargetData.depthTexture = depthTexture || null;
|
|
|
renderTargetData.depth = renderTarget.depthBuffer;
|
|
|
renderTargetData.stencil = renderTarget.stencilBuffer;
|
|
|
renderTargetData.renderTarget = renderTarget;
|
|
|
@@ -62210,7 +62216,12 @@ class Textures extends DataMap {
|
|
|
if ( renderTargetData.sampleCount !== sampleCount ) {
|
|
|
|
|
|
textureNeedsUpdate = true;
|
|
|
- depthTexture.needsUpdate = true;
|
|
|
+
|
|
|
+ if ( depthTexture ) {
|
|
|
+
|
|
|
+ depthTexture.needsUpdate = true;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
renderTargetData.sampleCount = sampleCount;
|
|
|
|
|
|
@@ -62230,7 +62241,11 @@ class Textures extends DataMap {
|
|
|
|
|
|
}
|
|
|
|
|
|
- this.updateTexture( depthTexture, options );
|
|
|
+ if ( depthTexture ) {
|
|
|
+
|
|
|
+ this.updateTexture( depthTexture, options );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// dispose handler
|
|
|
|
|
|
@@ -62250,7 +62265,11 @@ class Textures extends DataMap {
|
|
|
|
|
|
}
|
|
|
|
|
|
- this._destroyTexture( depthTexture );
|
|
|
+ if ( depthTexture ) {
|
|
|
+
|
|
|
+ this._destroyTexture( depthTexture );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
this.delete( renderTarget );
|
|
|
|
|
|
@@ -62621,8 +62640,6 @@ class Background extends DataMap {
|
|
|
|
|
|
if ( renderer.autoClear === true || forceClear === true ) {
|
|
|
|
|
|
- _clearColor.multiplyScalar( _clearColor.a );
|
|
|
-
|
|
|
const clearColorValue = renderContext.clearColorValue;
|
|
|
|
|
|
clearColorValue.r = _clearColor.r;
|
|
|
@@ -62630,6 +62647,18 @@ class Background extends DataMap {
|
|
|
clearColorValue.b = _clearColor.b;
|
|
|
clearColorValue.a = _clearColor.a;
|
|
|
|
|
|
+ // premultiply alpha
|
|
|
+
|
|
|
+ if ( renderer.backend.isWebGLBackend === true || renderer.alpha === true ) {
|
|
|
+
|
|
|
+ clearColorValue.r *= clearColorValue.a;
|
|
|
+ clearColorValue.g *= clearColorValue.a;
|
|
|
+ clearColorValue.b *= clearColorValue.a;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+
|
|
|
renderContext.depthClearValue = renderer._clearDepth;
|
|
|
renderContext.stencilClearValue = renderer._clearStencil;
|
|
|
|
|
|
@@ -69183,18 +69212,13 @@ class WebGLBufferRenderer {
|
|
|
}
|
|
|
|
|
|
let elementCount = 0;
|
|
|
-
|
|
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
|
|
|
|
- elementCount += counts[ i ];
|
|
|
+ elementCount += counts[ i ] * primcount[ i ];
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( let i = 0; i < primcount.length; i ++ ) {
|
|
|
-
|
|
|
- info.update( object, elementCount, mode, primcount[ i ] );
|
|
|
-
|
|
|
- }
|
|
|
+ info.update( object, elementCount, mode, 1 );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -69623,9 +69647,17 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
if ( descriptor === null ) {
|
|
|
|
|
|
+ const clearColor = this.getClearColor();
|
|
|
+
|
|
|
+ // premultiply alpha
|
|
|
+
|
|
|
+ clearColor.r *= clearColor.a;
|
|
|
+ clearColor.g *= clearColor.a;
|
|
|
+ clearColor.b *= clearColor.a;
|
|
|
+
|
|
|
descriptor = {
|
|
|
textures: null,
|
|
|
- clearColorValue: this.getClearColor()
|
|
|
+ clearColorValue: clearColor
|
|
|
};
|
|
|
|
|
|
}
|
|
|
@@ -69640,13 +69672,23 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
if ( clear !== 0 ) {
|
|
|
|
|
|
- const clearColor = descriptor.clearColorValue || this.getClearColor();
|
|
|
+ let clearColor;
|
|
|
|
|
|
- // premultiply alpha
|
|
|
+ if ( descriptor.clearColorValue ) {
|
|
|
|
|
|
- clearColor.r *= clearColor.a;
|
|
|
- clearColor.g *= clearColor.a;
|
|
|
- clearColor.b *= clearColor.a;
|
|
|
+ clearColor = descriptor.clearColorValue;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ clearColor = this.getClearColor();
|
|
|
+
|
|
|
+ // premultiply alpha
|
|
|
+
|
|
|
+ clearColor.r *= clearColor.a;
|
|
|
+ clearColor.g *= clearColor.a;
|
|
|
+ clearColor.b *= clearColor.a;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if ( depth ) this.state.setDepthMask( true );
|
|
|
|
|
|
@@ -74792,15 +74834,6 @@ class WebGPUPipelineUtils {
|
|
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
|
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
|
primitive: primitiveState,
|
|
|
- depthStencil: {
|
|
|
- format: depthStencilFormat,
|
|
|
- depthWriteEnabled: material.depthWrite,
|
|
|
- depthCompare: depthCompare,
|
|
|
- stencilFront: stencilFront,
|
|
|
- stencilBack: {}, // three.js does not provide an API to configure the back function (gl.stencilFuncSeparate() was never used)
|
|
|
- stencilReadMask: material.stencilFuncMask,
|
|
|
- stencilWriteMask: material.stencilWriteMask
|
|
|
- },
|
|
|
multisample: {
|
|
|
count: sampleCount,
|
|
|
alphaToCoverageEnabled: material.alphaToCoverage && sampleCount > 1
|
|
|
@@ -74810,6 +74843,35 @@ class WebGPUPipelineUtils {
|
|
|
} )
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+ const depthStencil = {};
|
|
|
+ const renderDepth = renderObject.context.depth;
|
|
|
+ const renderStencil = renderObject.context.stencil;
|
|
|
+
|
|
|
+ if ( renderDepth === true || renderStencil === true ) {
|
|
|
+
|
|
|
+ if ( renderDepth === true ) {
|
|
|
+
|
|
|
+ depthStencil.format = depthStencilFormat;
|
|
|
+ depthStencil.depthWriteEnabled = material.depthWrite;
|
|
|
+ depthStencil.depthCompare = depthCompare;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( renderStencil === true ) {
|
|
|
+
|
|
|
+ depthStencil.stencilFront = stencilFront;
|
|
|
+ depthStencil.stencilBack = {}; // three.js does not provide an API to configure the back function (gl.stencilFuncSeparate() was never used)
|
|
|
+ depthStencil.stencilReadMask = material.stencilFuncMask;
|
|
|
+ depthStencil.stencilWriteMask = material.stencilWriteMask;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ pipelineDescriptor.depthStencil = depthStencil;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if ( promises === null ) {
|
|
|
|
|
|
pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
|
|
|
@@ -75435,11 +75497,16 @@ class WebGPUBackend extends Backend {
|
|
|
colorAttachments: [ {
|
|
|
view: null
|
|
|
} ],
|
|
|
- depthStencilAttachment: {
|
|
|
- view: this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView()
|
|
|
- }
|
|
|
};
|
|
|
|
|
|
+ if ( this.renderer.depth === true || this.renderer.stencil === true ) {
|
|
|
+
|
|
|
+ descriptor.depthStencilAttachment = {
|
|
|
+ view: this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView()
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
const colorAttachment = descriptor.colorAttachments[ 0 ];
|
|
|
|
|
|
if ( this.renderer.samples > 0 ) {
|
|
|
@@ -75547,17 +75614,22 @@ class WebGPUBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- const depthTextureData = this.get( renderContext.depthTexture );
|
|
|
-
|
|
|
- const depthStencilAttachment = {
|
|
|
- view: depthTextureData.texture.createView()
|
|
|
- };
|
|
|
|
|
|
descriptor = {
|
|
|
colorAttachments,
|
|
|
- depthStencilAttachment
|
|
|
};
|
|
|
|
|
|
+ if ( renderContext.depth ) {
|
|
|
+
|
|
|
+ const depthTextureData = this.get( renderContext.depthTexture );
|
|
|
+
|
|
|
+ const depthStencilAttachment = {
|
|
|
+ view: depthTextureData.texture.createView()
|
|
|
+ };
|
|
|
+ descriptor.depthStencilAttachment = depthStencilAttachment;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
descriptors[ cacheKey ] = descriptor;
|
|
|
|
|
|
renderTargetData.width = renderTarget.width;
|