Skip to content

Commit 9cc9b3d

Browse files
committed
SSAOPass: Clean up
1 parent d0c8c6e commit 9cc9b3d

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

examples/js/postprocessing/SSAOPass.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,32 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
151151

152152
constructor: THREE.SSAOPass,
153153

154+
dispose: function () {
155+
156+
// dispose render targets
157+
158+
this.beautyRenderTarget.dispose();
159+
this.normalRenderTarget.dispose();
160+
this.ssaoRenderTarget.dispose();
161+
this.blurRenderTarget.dispose();
162+
163+
// dispose geometry
164+
165+
this.quad.geometry.dispose();
166+
167+
// dispose materials
168+
169+
this.normalMaterial.dispose();
170+
this.blurMaterial.dispose();
171+
this.copyMaterial.dispose();
172+
this.depthRenderMaterial.dispose();
173+
174+
},
175+
154176
render: function ( renderer, writeBuffer /*, readBuffer, delta, maskActive */ ) {
155177

156178
// render beauty and depth
157179

158-
renderer.setClearColor( 0x000000 );
159180
renderer.render( this.scene, this.camera, this.beautyRenderTarget, true );
160181

161182
// render normals
@@ -181,45 +202,45 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
181202

182203
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
183204
this.copyMaterial.blending = THREE.NoBlending;
184-
this.renderPass( renderer, this.copyMaterial, null, true );
205+
this.renderPass( renderer, this.copyMaterial, null );
185206

186207
break;
187208

188209
case THREE.SSAOPass.OUTPUT.Blur:
189210

190211
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
191212
this.copyMaterial.blending = THREE.NoBlending;
192-
this.renderPass( renderer, this.copyMaterial, null, true );
213+
this.renderPass( renderer, this.copyMaterial, null );
193214

194215
break;
195216

196217
case THREE.SSAOPass.OUTPUT.Beauty:
197218

198219
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
199220
this.copyMaterial.blending = THREE.NoBlending;
200-
this.renderPass( renderer, this.copyMaterial, null, true );
221+
this.renderPass( renderer, this.copyMaterial, null );
201222

202223
break;
203224

204225
case THREE.SSAOPass.OUTPUT.Depth:
205226

206-
this.renderPass( renderer, this.depthRenderMaterial, null, true );
227+
this.renderPass( renderer, this.depthRenderMaterial, null );
207228

208229
break;
209230

210231
case THREE.SSAOPass.OUTPUT.Normal:
211232

212233
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
213234
this.copyMaterial.blending = THREE.NoBlending;
214-
this.renderPass( renderer, this.copyMaterial, null, true );
235+
this.renderPass( renderer, this.copyMaterial, null );
215236

216237
break;
217238

218239
case THREE.SSAOPass.OUTPUT.Default:
219240

220241
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
221242
this.copyMaterial.blending = THREE.NoBlending;
222-
this.renderPass( renderer, this.copyMaterial, null, true );
243+
this.renderPass( renderer, this.copyMaterial, null );
223244

224245
this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
225246
this.copyMaterial.blending = THREE.CustomBlending;

0 commit comments

Comments
 (0)