Skip to content

Commit 2a5c541

Browse files
wereHamstercrobi
authored andcommitted
Make EffectComposer plugins use their own camera/scene/quad
This fixes # 2951.
1 parent f396baf commit 2a5c541

File tree

8 files changed

+61
-28
lines changed

8 files changed

+61
-28
lines changed

examples/js/postprocessing/BloomPass.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
6565
this.needsSwap = false;
6666
this.clear = false;
6767

68+
69+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
70+
this.scene = new THREE.Scene();
71+
72+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
73+
this.scene.add( this.quad );
74+
6875
};
6976

7077
THREE.BloomPass.prototype = {
@@ -75,30 +82,30 @@ THREE.BloomPass.prototype = {
7582

7683
// Render quad with blured scene into texture (convolution pass 1)
7784

78-
THREE.EffectComposer.quad.material = this.materialConvolution;
85+
this.quad.material = this.materialConvolution;
7986

8087
this.convolutionUniforms[ "tDiffuse" ].value = readBuffer;
8188
this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
8289

83-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTargetX, true );
90+
renderer.render( this.scene, this.camera, this.renderTargetX, true );
8491

8592

8693
// Render quad with blured scene into texture (convolution pass 2)
8794

8895
this.convolutionUniforms[ "tDiffuse" ].value = this.renderTargetX;
8996
this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurY;
9097

91-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTargetY, true );
98+
renderer.render( this.scene, this.camera, this.renderTargetY, true );
9299

93100
// Render original scene with superimposed blur to texture
94101

95-
THREE.EffectComposer.quad.material = this.materialCopy;
102+
this.quad.material = this.materialCopy;
96103

97104
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY;
98105

99106
if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
100107

101-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer, this.clear );
108+
renderer.render( this.scene, this.camera, readBuffer, this.clear );
102109

103110
}
104111

examples/js/postprocessing/DotScreenPass.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
2727
this.renderToScreen = false;
2828
this.needsSwap = true;
2929

30+
31+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
32+
this.scene = new THREE.Scene();
33+
34+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
35+
this.scene.add( this.quad );
36+
3037
};
3138

3239
THREE.DotScreenPass.prototype = {
@@ -36,15 +43,15 @@ THREE.DotScreenPass.prototype = {
3643
this.uniforms[ "tDiffuse" ].value = readBuffer;
3744
this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
3845

39-
THREE.EffectComposer.quad.material = this.material;
46+
this.quad.material = this.material;
4047

4148
if ( this.renderToScreen ) {
4249

43-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
50+
renderer.render( this.scene, this.camera );
4451

4552
} else {
4653

47-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
54+
renderer.render( this.scene, this.camera, writeBuffer, false );
4855

4956
}
5057

examples/js/postprocessing/EffectComposer.js

-9
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,3 @@ THREE.EffectComposer.prototype = {
133133
}
134134

135135
};
136-
137-
// shared ortho camera
138-
139-
THREE.EffectComposer.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
140-
141-
THREE.EffectComposer.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
142-
143-
THREE.EffectComposer.scene = new THREE.Scene();
144-
THREE.EffectComposer.scene.add( THREE.EffectComposer.quad );

examples/js/postprocessing/FilmPass.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
2828
this.renderToScreen = false;
2929
this.needsSwap = true;
3030

31+
32+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
33+
this.scene = new THREE.Scene();
34+
35+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
36+
this.scene.add( this.quad );
37+
3138
};
3239

3340
THREE.FilmPass.prototype = {
@@ -37,15 +44,15 @@ THREE.FilmPass.prototype = {
3744
this.uniforms[ "tDiffuse" ].value = readBuffer;
3845
this.uniforms[ "time" ].value += delta;
3946

40-
THREE.EffectComposer.quad.material = this.material;
47+
this.quad.material = this.material;
4148

4249
if ( this.renderToScreen ) {
4350

44-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
51+
renderer.render( this.scene, this.camera );
4552

4653
} else {
4754

48-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
55+
renderer.render( this.scene, this.camera, writeBuffer, false );
4956

5057
}
5158

examples/js/postprocessing/SavePass.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ THREE.SavePass = function ( renderTarget ) {
3434
this.needsSwap = false;
3535
this.clear = false;
3636

37+
38+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
39+
this.scene = new THREE.Scene();
40+
41+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
42+
this.scene.add( this.quad );
43+
3744
};
3845

3946
THREE.SavePass.prototype = {
@@ -46,9 +53,9 @@ THREE.SavePass.prototype = {
4653

4754
}
4855

49-
THREE.EffectComposer.quad.material = this.material;
56+
this.quad.material = this.material;
5057

51-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTarget, this.clear );
58+
renderer.render( this.scene, this.camera, this.renderTarget, this.clear );
5259

5360
}
5461

examples/js/postprocessing/ShaderPass.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ THREE.ShaderPass = function ( shader, textureID ) {
2222
this.needsSwap = true;
2323
this.clear = false;
2424

25+
26+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
27+
this.scene = new THREE.Scene();
28+
29+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
30+
this.scene.add( this.quad );
31+
2532
};
2633

2734
THREE.ShaderPass.prototype = {
@@ -34,15 +41,15 @@ THREE.ShaderPass.prototype = {
3441

3542
}
3643

37-
THREE.EffectComposer.quad.material = this.material;
44+
this.quad.material = this.material;
3845

3946
if ( this.renderToScreen ) {
4047

41-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
48+
renderer.render( this.scene, this.camera );
4249

4350
} else {
4451

45-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, this.clear );
52+
renderer.render( this.scene, this.camera, writeBuffer, this.clear );
4653

4754
}
4855

examples/js/postprocessing/TexturePass.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,22 @@ THREE.TexturePass = function ( texture, opacity ) {
2525
this.enabled = true;
2626
this.needsSwap = false;
2727

28+
29+
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
30+
this.scene = new THREE.Scene();
31+
32+
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
33+
this.scene.add( this.quad );
34+
2835
};
2936

3037
THREE.TexturePass.prototype = {
3138

3239
render: function ( renderer, writeBuffer, readBuffer, delta ) {
3340

34-
THREE.EffectComposer.quad.material = this.material;
41+
this.quad.material = this.material;
3542

36-
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer );
43+
renderer.render( this.scene, this.camera, readBuffer );
3744

3845
}
3946

examples/js/renderers/WebGLDeferredRenderer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
989989
passColor.camera = currentCamera;
990990
passNormalDepth.camera = currentCamera;
991991
passLightProxy.camera = currentCamera;
992-
passLightFullscreen.camera = THREE.EffectComposer.camera;
992+
passLightFullscreen.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
993993

994994
passColor.scene = scene;
995995
passNormalDepth.scene = scene;

0 commit comments

Comments
 (0)