Ver código fonte

Examples: Fix width/height handling in SSAOPass

Mugen87 6 anos atrás
pai
commit
6f6dab8461

+ 5 - 5
examples/js/postprocessing/SSAOPass.js

@@ -35,7 +35,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 	depthTexture.minFilter = THREE.NearestFilter;
 	depthTexture.minFilter = THREE.NearestFilter;
 	depthTexture.maxFilter = THREE.NearestFilter;
 	depthTexture.maxFilter = THREE.NearestFilter;
 
 
-	this.beautyRenderTarget = new THREE.WebGLRenderTarget( width, height, {
+	this.beautyRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
 		minFilter: THREE.LinearFilter,
 		minFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		format: THREE.RGBAFormat,
 		format: THREE.RGBAFormat,
@@ -45,7 +45,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 
 
 	// normal render target
 	// normal render target
 
 
-	this.normalRenderTarget = new THREE.WebGLRenderTarget( width, height, {
+	this.normalRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
 		minFilter: THREE.NearestFilter,
 		minFilter: THREE.NearestFilter,
 		magFilter: THREE.NearestFilter,
 		magFilter: THREE.NearestFilter,
 		format: THREE.RGBAFormat
 		format: THREE.RGBAFormat
@@ -53,7 +53,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 
 
 	// ssao render target
 	// ssao render target
 
 
-	this.ssaoRenderTarget = new THREE.WebGLRenderTarget( width, height, {
+	this.ssaoRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, {
 		minFilter: THREE.LinearFilter,
 		minFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		magFilter: THREE.LinearFilter,
 		format: THREE.RGBAFormat
 		format: THREE.RGBAFormat
@@ -84,7 +84,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 	this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
 	this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
 	this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
 	this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
 	this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
 	this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
-	this.ssaoMaterial.uniforms[ 'resolution' ].value.set( width, height );
+	this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
 	this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
 	this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
 	this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix );
 	this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix );
 
 
@@ -102,7 +102,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 		fragmentShader: THREE.SSAOBlurShader.fragmentShader
 		fragmentShader: THREE.SSAOBlurShader.fragmentShader
 	} );
 	} );
 	this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
 	this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
-	this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
+	this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
 
 
 	// material for rendering the depth
 	// material for rendering the depth
 
 

+ 4 - 1
examples/webgl_postprocessing_ssao.html

@@ -119,7 +119,10 @@
 				stats = new Stats();
 				stats = new Stats();
 				container.appendChild( stats.dom );
 				container.appendChild( stats.dom );
 
 
-				ssaoPass = new THREE.SSAOPass( scene, camera );
+				var width = window.innerWidth;
+				var height = window.innerHeight;
+
+				ssaoPass = new THREE.SSAOPass( scene, camera, width, height );
 				ssaoPass.renderToScreen = true;
 				ssaoPass.renderToScreen = true;
 
 
 				effectComposer = new THREE.EffectComposer( renderer );
 				effectComposer = new THREE.EffectComposer( renderer );