Skip to content

Commit 463a8a6

Browse files
bhoustonmrdoob
authored andcommitted
Pass.setSize - make resizing of passes automatic through EffectComposer.setSize (mrdoob#8925)
* add Pass.setSize() and have it called automatically by EffectComposer.setSize() * fix minor bugs in EffectComposer.setSize routine. * fix buggy prototype usage in Pass derived classes. * fix buggy prototype usage in Pass derived classes. * remove constructors as suggested by @mrdoob * fix MaskPass's prototype. * init pass side when added to compositor. * tabify EffectComposer.js * simplify for loop.
1 parent a5c253c commit 463a8a6

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

examples/js/postprocessing/EffectComposer.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ THREE.EffectComposer.prototype = {
4848

4949
this.passes.push( pass );
5050

51+
var size = this.renderer.getSize();
52+
pass.setSize( size.width, size.height );
53+
5154
},
5255

5356
insertPass: function ( pass, index ) {
@@ -131,35 +134,43 @@ THREE.EffectComposer.prototype = {
131134
this.renderTarget1.setSize( width, height );
132135
this.renderTarget2.setSize( width, height );
133136

137+
for ( var i = 0; i < this.passes.length; i ++ ) {
138+
139+
this.passes[i].setSize( width, height );
140+
141+
}
142+
134143
}
135144

136145
};
137146

138147

139148
THREE.Pass = function () {
140149

141-
// if set to true, the pass is processed by the composer
142-
this.enabled = true;
150+
// if set to true, the pass is processed by the composer
151+
this.enabled = true;
143152

144-
// if set to true, the pass indicates to swap read and write buffer after rendering
145-
this.needsSwap = true;
153+
// if set to true, the pass indicates to swap read and write buffer after rendering
154+
this.needsSwap = true;
146155

147-
// if set to true, the pass clears its buffer before rendering
148-
this.clear = false;
156+
// if set to true, the pass clears its buffer before rendering
157+
this.clear = false;
149158

150-
// if set to true, the result of the pass is rendered to screen
151-
this.renderToScreen = false;
159+
// if set to true, the result of the pass is rendered to screen
160+
this.renderToScreen = false;
152161

153162
};
154163

155164
THREE.Pass.prototype = {
156165

157-
constructor: THREE.Pass,
166+
constructor: THREE.Pass,
167+
168+
setSize: function( width, height ) {},
158169

159-
render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
170+
render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
160171

161172
console.error( "THREE.Pass: .render() must be implemented in derived pass." );
162173

163-
}
174+
}
164175

165176
};

examples/js/postprocessing/SMAAPass.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/postprocessing/TAARenderPass.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ THREE.TAARenderPass = function ( scene, camera, params ) {
2929
THREE.TAARenderPass.JitterVectors = THREE.ManualMSAARenderPass.JitterVectors;
3030

3131
THREE.TAARenderPass.prototype = Object.create( THREE.ManualMSAARenderPass.prototype );
32+
3233
Object.assign( THREE.TAARenderPass.prototype, {
3334

3435
render: function ( renderer, writeBuffer, readBuffer, delta ) {

examples/webgl_postprocessing_msaa.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
var newWidth = Math.floor( width / pixelRatio ) || 1;
154154
var newHeight = Math.floor( height / pixelRatio ) || 1;
155155
composer.setSize( newWidth, newHeight );
156-
msaaRenderPass.setSize( newWidth, newHeight );
157156

158157
}
159158

examples/webgl_postprocessing_smaa.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
var newWidth = Math.floor( width / pixelRatio ) || 1;
9999
var newHeight = Math.floor( height / pixelRatio ) || 1;
100100
composer.setSize( newWidth, newHeight );
101-
pass.setSize( newWidth, newHeight );
102101

103102
}
104103

examples/webgl_postprocessing_taa.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
var newWidth = Math.floor( width / pixelRatio ) || 1;
173173
var newHeight = Math.floor( height / pixelRatio ) || 1;
174174
composer.setSize( newWidth, newHeight );
175-
taaRenderPass.setSize( newWidth, newHeight );
176175

177176
}
178177

0 commit comments

Comments
 (0)