|
@@ -131,14 +131,9 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
|
|
|
this.oldClearColor = new THREE.Color();
|
|
|
this.oldClearAlpha = 1;
|
|
|
|
|
|
- this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
|
- this.scene = new THREE.Scene();
|
|
|
-
|
|
|
this.basic = new THREE.MeshBasicMaterial();
|
|
|
|
|
|
- this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
|
|
|
- this.quad.frustumCulled = false; // Avoid getting clipped
|
|
|
- this.scene.add( this.quad );
|
|
|
+ this.fillQuad = THREE.Pass.createFillQuadScene( null );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -200,12 +195,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
|
|
|
|
|
|
if ( this.renderToScreen ) {
|
|
|
|
|
|
- this.quad.material = this.basic;
|
|
|
+ this.fillQuad.quad.material = this.basic;
|
|
|
this.basic.map = readBuffer.texture;
|
|
|
|
|
|
renderer.setRenderTarget( null );
|
|
|
renderer.clear();
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -213,11 +208,11 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
|
|
|
|
|
|
this.highPassUniforms[ "tDiffuse" ].value = readBuffer.texture;
|
|
|
this.highPassUniforms[ "luminosityThreshold" ].value = this.threshold;
|
|
|
- this.quad.material = this.materialHighPassFilter;
|
|
|
+ this.fillQuad.quad.material = this.materialHighPassFilter;
|
|
|
|
|
|
renderer.setRenderTarget( this.renderTargetBright );
|
|
|
renderer.clear();
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
// 2. Blur All the mips progressively
|
|
|
|
|
@@ -225,19 +220,19 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
|
|
|
|
|
|
for ( var i = 0; i < this.nMips; i ++ ) {
|
|
|
|
|
|
- this.quad.material = this.separableBlurMaterials[ i ];
|
|
|
+ this.fillQuad.quad.material = this.separableBlurMaterials[ i ];
|
|
|
|
|
|
this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = inputRenderTarget.texture;
|
|
|
this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionX;
|
|
|
renderer.setRenderTarget( this.renderTargetsHorizontal[ i ] );
|
|
|
renderer.clear();
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = this.renderTargetsHorizontal[ i ].texture;
|
|
|
this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionY;
|
|
|
renderer.setRenderTarget( this.renderTargetsVertical[ i ] );
|
|
|
renderer.clear();
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
inputRenderTarget = this.renderTargetsVertical[ i ];
|
|
|
|
|
@@ -245,18 +240,18 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
|
|
|
|
|
|
// Composite All the mips
|
|
|
|
|
|
- this.quad.material = this.compositeMaterial;
|
|
|
+ this.fillQuad.quad.material = this.compositeMaterial;
|
|
|
this.compositeMaterial.uniforms[ "bloomStrength" ].value = this.strength;
|
|
|
this.compositeMaterial.uniforms[ "bloomRadius" ].value = this.radius;
|
|
|
this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors;
|
|
|
|
|
|
renderer.setRenderTarget( this.renderTargetsHorizontal[ 0 ] );
|
|
|
renderer.clear();
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
// Blend it additively over the input texture
|
|
|
|
|
|
- this.quad.material = this.materialCopy;
|
|
|
+ this.fillQuad.quad.material = this.materialCopy;
|
|
|
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture;
|
|
|
|
|
|
if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
|
|
@@ -265,12 +260,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
|
|
|
if ( this.renderToScreen ) {
|
|
|
|
|
|
renderer.setRenderTarget( null );
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
renderer.setRenderTarget( readBuffer );
|
|
|
- renderer.render( this.scene, this.camera );
|
|
|
+ renderer.render( this.fillQuad.scene, this.fillQuad.camera );
|
|
|
|
|
|
}
|
|
|
|