Skip to content

Commit 99a8d81

Browse files
authored
WebGLRenderer: Auto-correct reversed projection matrix (#31410)
* Auto-correct projection matrix
1 parent 96662ca commit 99a8d81

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/renderers/WebGLRenderer.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { WebGLUtils } from './webgl/WebGLUtils.js';
5252
import { WebXRManager } from './webxr/WebXRManager.js';
5353
import { WebGLMaterials } from './webgl/WebGLMaterials.js';
5454
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
55-
import { createCanvasElement, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix, warnOnce } from '../utils.js';
55+
import { createCanvasElement, probeAsync, warnOnce } from '../utils.js';
5656
import { ColorManagement } from '../math/ColorManagement.js';
5757

5858
/**
@@ -313,7 +313,6 @@ class WebGLRenderer {
313313

314314
// camera matrices cache
315315

316-
const _currentProjectionMatrix = new Matrix4();
317316
const _projScreenMatrix = new Matrix4();
318317

319318
const _vector3 = new Vector3();
@@ -2384,22 +2383,13 @@ class WebGLRenderer {
23842383

23852384
if ( reversedDepthBuffer && camera.reversedDepth !== true ) {
23862385

2387-
// @deprecated, r179
2388-
warnOnce( 'THREE.WebGLRenderer: reversedDepthBuffer must be used with "camera.reversedDepth = true;" for correct results. Automatic conversion will be removed in r189.' );
2389-
2390-
_currentProjectionMatrix.copy( camera.projectionMatrix );
2391-
2392-
toNormalizedProjectionMatrix( _currentProjectionMatrix );
2393-
toReversedProjectionMatrix( _currentProjectionMatrix );
2394-
2395-
p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
2396-
2397-
} else {
2398-
2399-
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
2386+
camera.reversedDepth = true;
2387+
camera.updateProjectionMatrix();
24002388

24012389
}
24022390

2391+
p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
2392+
24032393
p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
24042394

24052395
const uCamPos = p_uniforms.map.cameraPosition;

0 commit comments

Comments
 (0)