Skip to content

Commit

Permalink
Merge pull request #20577 from gonnavis/SSAOUseCameraProjectionMatrix…
Browse files Browse the repository at this point in the history
…Inverse

Use copy( camera.projectionMatrixInverse ) instead of getInverse( camera.projectionMatrix )
  • Loading branch information
mrdoob committed Oct 29, 2020
2 parents 95ef309 + e840f31 commit 0b7b86f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/js/postprocessing/SAOPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions examples/js/postprocessing/SSAOPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 );

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

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/postprocessing/SSAOPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions examples/webgl_raymarching_reflect.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 );

}

Expand Down

0 comments on commit 0b7b86f

Please sign in to comment.