diff --git a/examples/jsm/csm/CSMFrustum.js b/examples/jsm/csm/CSMFrustum.js index 8e8a97df6e1217..f34d26ff577428 100644 --- a/examples/jsm/csm/CSMFrustum.js +++ b/examples/jsm/csm/CSMFrustum.js @@ -27,6 +27,13 @@ class CSMFrustum { */ this.zNear = data.webGL === true ? - 1 : 0; + /** + * The zFar value. + * + * @type {number} + */ + this.zFar = 1; + /** * An object representing the vertices of the near and * far plane in view space. @@ -54,6 +61,15 @@ class CSMFrustum { } + // In case of reversed depth buffer, zNear and zFar must be 1 and 0 + // respectively regardless of the coordinate system. + if ( data.reversedDepth === true ) { + + this.zNear = 1; + this.zFar = 0; + + } + } /** @@ -66,6 +82,7 @@ class CSMFrustum { setFromProjectionMatrix( projectionMatrix, maxFar ) { const zNear = this.zNear; + const zFar = this.zFar; const isOrthographic = projectionMatrix.elements[ 2 * 4 + 3 ] === 0; inverseProjectionMatrix.copy( projectionMatrix ).invert(); @@ -85,10 +102,10 @@ class CSMFrustum { } ); - this.vertices.far[ 0 ].set( 1, 1, 1 ); - this.vertices.far[ 1 ].set( 1, - 1, 1 ); - this.vertices.far[ 2 ].set( - 1, - 1, 1 ); - this.vertices.far[ 3 ].set( - 1, 1, 1 ); + this.vertices.far[ 0 ].set( 1, 1, zFar ); + this.vertices.far[ 1 ].set( 1, - 1, zFar ); + this.vertices.far[ 2 ].set( - 1, - 1, zFar ); + this.vertices.far[ 3 ].set( - 1, 1, zFar ); this.vertices.far.forEach( function ( v ) { v.applyMatrix4( inverseProjectionMatrix ); @@ -202,6 +219,7 @@ class CSMFrustum { * * @typedef {Object} CSMFrustum~Data * @property {boolean} [webGL] - Whether this CSM frustum is used with WebGL or WebGPU. + * @property {boolean} [reversedDepth] - Whether reversed depth buffer is enabled. * @property {Matrix4} [projectionMatrix] - A projection matrix usually of the scene's camera. * @property {number} [maxFar] - The maximum far value. **/ diff --git a/examples/jsm/csm/CSMShadowNode.js b/examples/jsm/csm/CSMShadowNode.js index 4e2ae5b55c228d..84984a8f708029 100644 --- a/examples/jsm/csm/CSMShadowNode.js +++ b/examples/jsm/csm/CSMShadowNode.js @@ -159,7 +159,10 @@ class CSMShadowNode extends ShadowBaseNode { this.camera = camera; - const data = { webGL: renderer.coordinateSystem === WebGLCoordinateSystem }; + const data = { + webGL: renderer.coordinateSystem === WebGLCoordinateSystem, + reversedDepth: renderer.reversedDepthBuffer + }; this.mainFrustum = new CSMFrustum( data ); const light = this.light; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index a63971cd0bce20..ab28669f542ae7 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -728,7 +728,7 @@ class WebGLRenderer { if ( _outputBufferType === UnsignedByteType ) { - error( 'THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' ); + error( 'WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' ); return; } @@ -739,7 +739,7 @@ class WebGLRenderer { if ( effects[ i ].isOutputPass === true ) { - warn( 'THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' ); + warn( 'WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' ); break; } diff --git a/src/renderers/webgl-fallback/WebGLBackend.js b/src/renderers/webgl-fallback/WebGLBackend.js index f63ee32669d2f0..1ef89923d982d8 100644 --- a/src/renderers/webgl-fallback/WebGLBackend.js +++ b/src/renderers/webgl-fallback/WebGLBackend.js @@ -1621,7 +1621,7 @@ class WebGLBackend extends Backend { const fragmentErrors = this._getShaderErrors( gl, glFragmentShader, 'fragment' ); error( - 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' + + 'WebGLProgram: Shader Error ' + gl.getError() + ' - ' + 'VALIDATE_STATUS ' + gl.getProgramParameter( programGPU, gl.VALIDATE_STATUS ) + '\n\n' + 'Program Info Log: ' + programLog + '\n' + vertexErrors + '\n' + diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js index f009b39224e76d..743a04b9402dbb 100644 --- a/src/renderers/webgl/WebGLProgram.js +++ b/src/renderers/webgl/WebGLProgram.js @@ -888,7 +888,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) { const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' ); error( - 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' + + 'WebGLProgram: Shader Error ' + gl.getError() + ' - ' + 'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' + 'Material Name: ' + self.name + '\n' + 'Material Type: ' + self.type + '\n\n' +