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
26 changes: 22 additions & 4 deletions examples/jsm/csm/CSMFrustum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

}

}

/**
Expand All @@ -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();
Expand All @@ -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 );
Expand Down Expand Up @@ -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.
**/
Expand Down
5 changes: 4 additions & 1 deletion examples/jsm/csm/CSMShadowNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand All @@ -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;

}
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl/WebGLProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down
Loading