Skip to content

Commit cdd956e

Browse files
authored
Merge pull request #18425 from WestLangley/dev_outline_pass
OutlinePass: avoid unnecessary instantiation of objects
2 parents 3346310 + 898020b commit cdd956e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

examples/js/postprocessing/OutlinePass.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
6767
var MAX_EDGE_GLOW = 4;
6868

6969
this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
70-
this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
70+
this.separableBlurMaterial1.uniforms[ "texSize" ].value.set( resx, resy );
7171
this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = 1;
7272
this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
73-
this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( Math.round( resx / 2 ), Math.round( resy / 2 ) );
73+
this.separableBlurMaterial2.uniforms[ "texSize" ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
7474
this.separableBlurMaterial2.uniforms[ "kernelRadius" ].value = MAX_EDGE_GLOW;
7575

7676
// Overlay material
@@ -142,15 +142,15 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
142142
this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
143143
this.renderTargetBlurBuffer1.setSize( resx, resy );
144144
this.renderTargetEdgeBuffer1.setSize( resx, resy );
145-
this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
145+
this.separableBlurMaterial1.uniforms[ "texSize" ].value.set( resx, resy );
146146

147147
resx = Math.round( resx / 2 );
148148
resy = Math.round( resy / 2 );
149149

150150
this.renderTargetBlurBuffer2.setSize( resx, resy );
151151
this.renderTargetEdgeBuffer2.setSize( resx, resy );
152152

153-
this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );
153+
this.separableBlurMaterial2.uniforms[ "texSize" ].value.set( resx, resy );
154154

155155
},
156156

@@ -285,7 +285,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
285285
// Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
286286
this.changeVisibilityOfNonSelectedObjects( false );
287287
this.renderScene.overrideMaterial = this.prepareMaskMaterial;
288-
this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new THREE.Vector2( this.renderCamera.near, this.renderCamera.far );
288+
this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value.set( this.renderCamera.near, this.renderCamera.far );
289289
this.prepareMaskMaterial.uniforms[ "depthTexture" ].value = this.renderTargetDepthBuffer.texture;
290290
this.prepareMaskMaterial.uniforms[ "textureMatrix" ].value = this.textureMatrix;
291291
renderer.setRenderTarget( this.renderTargetMaskBuffer );
@@ -317,7 +317,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
317317
// 3. Apply Edge Detection Pass
318318
this.fsQuad.material = this.edgeDetectionMaterial;
319319
this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture;
320-
this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new THREE.Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
320+
this.edgeDetectionMaterial.uniforms[ "texSize" ].value.set( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
321321
this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1;
322322
this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2;
323323
renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
@@ -390,7 +390,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
390390
uniforms: {
391391
"depthTexture": { value: null },
392392
"cameraNearFar": { value: new THREE.Vector2( 0.5, 0.5 ) },
393-
"textureMatrix": { value: new THREE.Matrix4() }
393+
"textureMatrix": { value: null }
394394
},
395395

396396
vertexShader: [

examples/jsm/postprocessing/OutlinePass.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ var OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
8787
var MAX_EDGE_GLOW = 4;
8888

8989
this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS );
90-
this.separableBlurMaterial1.uniforms[ "texSize" ].value = new Vector2( resx, resy );
90+
this.separableBlurMaterial1.uniforms[ "texSize" ].value.set( resx, resy );
9191
this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = 1;
9292
this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW );
93-
this.separableBlurMaterial2.uniforms[ "texSize" ].value = new Vector2( Math.round( resx / 2 ), Math.round( resy / 2 ) );
93+
this.separableBlurMaterial2.uniforms[ "texSize" ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) );
9494
this.separableBlurMaterial2.uniforms[ "kernelRadius" ].value = MAX_EDGE_GLOW;
9595

9696
// Overlay material
@@ -162,15 +162,15 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
162162
this.renderTargetMaskDownSampleBuffer.setSize( resx, resy );
163163
this.renderTargetBlurBuffer1.setSize( resx, resy );
164164
this.renderTargetEdgeBuffer1.setSize( resx, resy );
165-
this.separableBlurMaterial1.uniforms[ "texSize" ].value = new Vector2( resx, resy );
165+
this.separableBlurMaterial1.uniforms[ "texSize" ].value.set( resx, resy );
166166

167167
resx = Math.round( resx / 2 );
168168
resy = Math.round( resy / 2 );
169169

170170
this.renderTargetBlurBuffer2.setSize( resx, resy );
171171
this.renderTargetEdgeBuffer2.setSize( resx, resy );
172172

173-
this.separableBlurMaterial2.uniforms[ "texSize" ].value = new Vector2( resx, resy );
173+
this.separableBlurMaterial2.uniforms[ "texSize" ].value.set( resx, resy );
174174

175175
},
176176

@@ -305,7 +305,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
305305
// Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
306306
this.changeVisibilityOfNonSelectedObjects( false );
307307
this.renderScene.overrideMaterial = this.prepareMaskMaterial;
308-
this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new Vector2( this.renderCamera.near, this.renderCamera.far );
308+
this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value.set( this.renderCamera.near, this.renderCamera.far );
309309
this.prepareMaskMaterial.uniforms[ "depthTexture" ].value = this.renderTargetDepthBuffer.texture;
310310
this.prepareMaskMaterial.uniforms[ "textureMatrix" ].value = this.textureMatrix;
311311
renderer.setRenderTarget( this.renderTargetMaskBuffer );
@@ -337,7 +337,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
337337
// 3. Apply Edge Detection Pass
338338
this.fsQuad.material = this.edgeDetectionMaterial;
339339
this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture;
340-
this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
340+
this.edgeDetectionMaterial.uniforms[ "texSize" ].value.set( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
341341
this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1;
342342
this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2;
343343
renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
@@ -410,7 +410,7 @@ OutlinePass.prototype = Object.assign( Object.create( Pass.prototype ), {
410410
uniforms: {
411411
"depthTexture": { value: null },
412412
"cameraNearFar": { value: new Vector2( 0.5, 0.5 ) },
413-
"textureMatrix": { value: new Matrix4() }
413+
"textureMatrix": { value: null }
414414
},
415415

416416
vertexShader: [

0 commit comments

Comments
 (0)