From c61b301402f17c8521e0f36a5176f72cde84ba92 Mon Sep 17 00:00:00 2001 From: gonnavis Date: Thu, 29 Oct 2020 11:35:58 +0800 Subject: [PATCH 1/2] SSAOUseCameraProjectionMatrixInverse --- examples/js/postprocessing/SSAOPass.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/js/postprocessing/SSAOPass.js b/examples/js/postprocessing/SSAOPass.js index 88fa8ac7c20efc..2e83c7d38bcd56 100644 --- a/examples/js/postprocessing/SSAOPass.js +++ b/examples/js/postprocessing/SSAOPass.js @@ -83,7 +83,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) { this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix ); - this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material @@ -322,7 +322,7 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), this.ssaoMaterial.uniforms[ 'resolution' ].value.set( width, height ); this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix ); - this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height ); From e840f31772593a51e9b01ce0f5e9c6a3c2c9366c Mon Sep 17 00:00:00 2001 From: gonnavis Date: Thu, 29 Oct 2020 11:51:46 +0800 Subject: [PATCH 2/2] Change all, not just SSAO --- examples/js/postprocessing/SAOPass.js | 4 ++-- examples/jsm/postprocessing/SAOPass.js | 4 ++-- examples/jsm/postprocessing/SSAOPass.js | 4 ++-- examples/webgl_raymarching_reflect.html | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/js/postprocessing/SAOPass.js b/examples/js/postprocessing/SAOPass.js index 9fda53b250ddb9..05ad526e909fb2 100644 --- a/examples/js/postprocessing/SAOPass.js +++ b/examples/js/postprocessing/SAOPass.js @@ -87,7 +87,7 @@ THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture; this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture; this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y ); - this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; this.saoMaterial.blending = THREE.NoBlending; @@ -376,7 +376,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), this.depthRenderTarget.setSize( width, height ); this.saoMaterial.uniforms[ 'size' ].value.set( width, height ); - this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; this.saoMaterial.needsUpdate = true; diff --git a/examples/jsm/postprocessing/SAOPass.js b/examples/jsm/postprocessing/SAOPass.js index 0b9a59a480e651..c5c2498f711699 100644 --- a/examples/jsm/postprocessing/SAOPass.js +++ b/examples/jsm/postprocessing/SAOPass.js @@ -115,7 +115,7 @@ var SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) { this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture; this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture; this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y ); - this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; this.saoMaterial.blending = NoBlending; @@ -404,7 +404,7 @@ SAOPass.prototype = Object.assign( Object.create( Pass.prototype ), { this.depthRenderTarget.setSize( width, height ); this.saoMaterial.uniforms[ 'size' ].value.set( width, height ); - this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; this.saoMaterial.needsUpdate = true; diff --git a/examples/jsm/postprocessing/SSAOPass.js b/examples/jsm/postprocessing/SSAOPass.js index 9c628849125054..5e0f72cfd7ff8a 100644 --- a/examples/jsm/postprocessing/SSAOPass.js +++ b/examples/jsm/postprocessing/SSAOPass.js @@ -113,7 +113,7 @@ var SSAOPass = function ( scene, camera, width, height ) { this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height ); this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix ); - this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); // normal material @@ -352,7 +352,7 @@ SSAOPass.prototype = Object.assign( Object.create( Pass.prototype ), { this.ssaoMaterial.uniforms[ 'resolution' ].value.set( width, height ); this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix ); - this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse ); this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height ); diff --git a/examples/webgl_raymarching_reflect.html b/examples/webgl_raymarching_reflect.html index 66eec67790440c..d79a03752b6000 100644 --- a/examples/webgl_raymarching_reflect.html +++ b/examples/webgl_raymarching_reflect.html @@ -289,7 +289,7 @@ uniforms: { resolution: { value: new THREE.Vector2( canvas.width, canvas.height ) }, cameraWorldMatrix: { value: camera.matrixWorld }, - cameraProjectionMatrixInverse: { value: new THREE.Matrix4().getInverse( camera.projectionMatrix ) } + cameraProjectionMatrixInverse: { value: new THREE.Matrix4().copy( camera.projectionMatrixInverse ) } }, vertexShader: document.getElementById( 'vertex_shader' ).textContent, fragmentShader: document.getElementById( 'fragment_shader' ).textContent @@ -328,7 +328,7 @@ camera.updateProjectionMatrix(); material.uniforms.resolution.value.set( canvas.width, canvas.height ); - material.uniforms.cameraProjectionMatrixInverse.value.getInverse( camera.projectionMatrix ); + material.uniforms.cameraProjectionMatrixInverse.value.copy( camera.projectionMatrixInverse ); }