提交 ba4bbfbe 编写于 作者: O Olli Etuaho

Better naming and API for full-screen quads

Now the same geometry and camera are shared between full-screen quad instances. A mesh is still created for each full-screen quad instance since that avoids repeatedly setting the material on the mesh in cases where a pass only needs one material.
上级 1dfd109a
...@@ -117,7 +117,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { ...@@ -117,7 +117,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
blending: THREE.NoBlending blending: THREE.NoBlending
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -141,35 +141,35 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa ...@@ -141,35 +141,35 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
if ( this.adaptive ) { if ( this.adaptive ) {
//Render the luminance of the current scene into a render target with mipmapping enabled //Render the luminance of the current scene into a render target with mipmapping enabled
this.fillQuad.quad.material = this.materialLuminance; this.fsQuad.material = this.materialLuminance;
this.materialLuminance.uniforms.tDiffuse.value = readBuffer.texture; this.materialLuminance.uniforms.tDiffuse.value = readBuffer.texture;
renderer.setRenderTarget( this.currentLuminanceRT ); renderer.setRenderTarget( this.currentLuminanceRT );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
//Use the new luminance values, the previous luminance and the frame delta to //Use the new luminance values, the previous luminance and the frame delta to
//adapt the luminance over time. //adapt the luminance over time.
this.fillQuad.quad.material = this.materialAdaptiveLum; this.fsQuad.material = this.materialAdaptiveLum;
this.materialAdaptiveLum.uniforms.delta.value = deltaTime; this.materialAdaptiveLum.uniforms.delta.value = deltaTime;
this.materialAdaptiveLum.uniforms.lastLum.value = this.previousLuminanceRT.texture; this.materialAdaptiveLum.uniforms.lastLum.value = this.previousLuminanceRT.texture;
this.materialAdaptiveLum.uniforms.currentLum.value = this.currentLuminanceRT.texture; this.materialAdaptiveLum.uniforms.currentLum.value = this.currentLuminanceRT.texture;
renderer.setRenderTarget( this.luminanceRT ); renderer.setRenderTarget( this.luminanceRT );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
//Copy the new adapted luminance value so that it can be used by the next frame. //Copy the new adapted luminance value so that it can be used by the next frame.
this.fillQuad.quad.material = this.materialCopy; this.fsQuad.material = this.materialCopy;
this.copyUniforms.tDiffuse.value = this.luminanceRT.texture; this.copyUniforms.tDiffuse.value = this.luminanceRT.texture;
renderer.setRenderTarget( this.previousLuminanceRT ); renderer.setRenderTarget( this.previousLuminanceRT );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
this.fillQuad.quad.material = this.materialToneMap; this.fsQuad.material = this.materialToneMap;
this.materialToneMap.uniforms.tDiffuse.value = readBuffer.texture; this.materialToneMap.uniforms.tDiffuse.value = readBuffer.texture;
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
...@@ -177,7 +177,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa ...@@ -177,7 +177,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
...@@ -225,7 +225,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa ...@@ -225,7 +225,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
} }
//Put something in the adaptive luminance texture so that the scene can render initially //Put something in the adaptive luminance texture so that the scene can render initially
this.fillQuad.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } ); this.fsQuad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } );
this.materialLuminance.needsUpdate = true; this.materialLuminance.needsUpdate = true;
this.materialAdaptiveLum.needsUpdate = true; this.materialAdaptiveLum.needsUpdate = true;
this.materialToneMap.needsUpdate = true; this.materialToneMap.needsUpdate = true;
......
...@@ -39,12 +39,12 @@ THREE.AfterimagePass = function ( damp ) { ...@@ -39,12 +39,12 @@ THREE.AfterimagePass = function ( damp ) {
} ); } );
this.compFillQuad = THREE.Pass.createFillQuadScene( this.shaderMaterial ); this.compFsQuad = new THREE.Pass.FullScreenQuad( this.shaderMaterial );
var material = new THREE.MeshBasicMaterial( { var material = new THREE.MeshBasicMaterial( {
map: this.textureComp.texture map: this.textureComp.texture
} ); } );
this.screenFillQuad = THREE.Pass.createFillQuadScene( material ); this.screenFsQuad = new THREE.Pass.FullScreenQuad( material );
}; };
...@@ -58,15 +58,15 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -58,15 +58,15 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
this.uniforms[ "tNew" ].value = readBuffer.texture; this.uniforms[ "tNew" ].value = readBuffer.texture;
renderer.setRenderTarget( this.textureComp ); renderer.setRenderTarget( this.textureComp );
renderer.render( this.compFillQuad.quad, this.compFillQuad.camera ); this.compFsQuad.render( renderer );
renderer.setRenderTarget( this.textureOld ); renderer.setRenderTarget( this.textureOld );
renderer.render( this.screenFillQuad.quad, this.screenFillQuad.camera ); this.screenFsQuad.render( renderer );
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.screenFillQuad.quad, this.screenFillQuad.camera ); this.screenFsQuad.render( renderer );
} else { } else {
...@@ -74,7 +74,7 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -74,7 +74,7 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.screenFillQuad.quad, this.screenFillQuad.camera ); this.screenFsQuad.render( renderer );
} }
......
...@@ -67,7 +67,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) { ...@@ -67,7 +67,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
this.needsSwap = false; this.needsSwap = false;
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -81,14 +81,14 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) ...@@ -81,14 +81,14 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
// Render quad with blured scene into texture (convolution pass 1) // Render quad with blured scene into texture (convolution pass 1)
this.fillQuad.quad.material = this.materialConvolution; this.fsQuad.material = this.materialConvolution;
this.convolutionUniforms[ "tDiffuse" ].value = readBuffer.texture; this.convolutionUniforms[ "tDiffuse" ].value = readBuffer.texture;
this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX; this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
renderer.setRenderTarget( this.renderTargetX ); renderer.setRenderTarget( this.renderTargetX );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// Render quad with blured scene into texture (convolution pass 2) // Render quad with blured scene into texture (convolution pass 2)
...@@ -98,11 +98,11 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) ...@@ -98,11 +98,11 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
renderer.setRenderTarget( this.renderTargetY ); renderer.setRenderTarget( this.renderTargetY );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// Render original scene with superimposed blur to texture // Render original scene with superimposed blur to texture
this.fillQuad.quad.material = this.materialCopy; this.fsQuad.material = this.materialCopy;
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture; this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture;
...@@ -110,7 +110,7 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) ...@@ -110,7 +110,7 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
renderer.setRenderTarget( readBuffer ); renderer.setRenderTarget( readBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -66,7 +66,7 @@ THREE.BokehPass = function ( scene, camera, params ) { ...@@ -66,7 +66,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
this.uniforms = bokehUniforms; this.uniforms = bokehUniforms;
this.needsSwap = false; this.needsSwap = false;
this.fillQuad = THREE.Pass.createFillQuadScene( this.materialBokeh ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.materialBokeh );
this.oldClearColor = new THREE.Color(); this.oldClearColor = new THREE.Color();
this.oldClearAlpha = 1; this.oldClearAlpha = 1;
...@@ -103,13 +103,13 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) ...@@ -103,13 +103,13 @@ THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype )
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -25,7 +25,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) { ...@@ -25,7 +25,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
}; };
...@@ -41,13 +41,13 @@ THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototy ...@@ -41,13 +41,13 @@ THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototy
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -192,28 +192,50 @@ THREE.Pass = function () { ...@@ -192,28 +192,50 @@ THREE.Pass = function () {
}; };
// Helper for passes that need a scene that simply has the whole viewport filled with a single quad. Object.assign( THREE.Pass.prototype, {
THREE.Pass.createFillQuadScene = function( material ) {
setSize: function ( width, height ) {},
render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
var fillQuad = {}; }
fillQuad.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); } );
fillQuad.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), material ); // Helper for passes that need to fill the viewport with a single quad.
fillQuad.quad.frustumCulled = false; // Avoid getting clipped THREE.Pass.FullScreenQuad = function ( material ) {
return fillQuad; this._mesh = new THREE.Mesh( THREE.Pass.FullScreenQuad._geometry, material );
}; };
Object.assign( THREE.Pass.prototype, { Object.defineProperty( THREE.Pass.FullScreenQuad.prototype, 'material', {
setSize: function ( width, height ) {}, get: function () {
render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) { return this._mesh.material;
console.error( 'THREE.Pass: .render() must be implemented in derived pass.' ); },
set: function ( value ) {
this._mesh.material = value;
}
} );
Object.assign( THREE.Pass.FullScreenQuad.prototype, {
render: function ( renderer ) {
renderer.render( this._mesh, THREE.Pass.FullScreenQuad._camera );
} }
} ); } );
THREE.Pass.FullScreenQuad._camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
THREE.Pass.FullScreenQuad._geometry = new THREE.PlaneBufferGeometry( 2, 2 );
...@@ -26,7 +26,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, ...@@ -26,7 +26,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
}; };
...@@ -42,13 +42,13 @@ THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), ...@@ -42,13 +42,13 @@ THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -23,7 +23,7 @@ THREE.GlitchPass = function ( dt_size ) { ...@@ -23,7 +23,7 @@ THREE.GlitchPass = function ( dt_size ) {
fragmentShader: shader.fragmentShader fragmentShader: shader.fragmentShader
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
this.goWild = false; this.goWild = false;
this.curF = 0; this.curF = 0;
...@@ -72,13 +72,13 @@ THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -72,13 +72,13 @@ THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -36,7 +36,7 @@ THREE.HalftonePass = function ( width, height, params ) { ...@@ -36,7 +36,7 @@ THREE.HalftonePass = function ( width, height, params ) {
} }
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
}; };
...@@ -51,13 +51,13 @@ THREE.HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototyp ...@@ -51,13 +51,13 @@ THREE.HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototyp
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -101,7 +101,7 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) { ...@@ -101,7 +101,7 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) {
this.oldClearColor = new THREE.Color(); this.oldClearColor = new THREE.Color();
this.oldClearAlpha = 1; this.oldClearAlpha = 1;
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
this.tempPulseColor1 = new THREE.Color(); this.tempPulseColor1 = new THREE.Color();
this.tempPulseColor2 = new THREE.Color(); this.tempPulseColor2 = new THREE.Color();
...@@ -297,11 +297,11 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -297,11 +297,11 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
this.renderScene.background = currentBackground; this.renderScene.background = currentBackground;
// 2. Downsample to Half resolution // 2. Downsample to Half resolution
this.fillQuad.quad.material = this.materialCopy; this.fsQuad.material = this.materialCopy;
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetMaskBuffer.texture; this.copyUniforms[ "tDiffuse" ].value = this.renderTargetMaskBuffer.texture;
renderer.setRenderTarget( this.renderTargetMaskDownSampleBuffer ); renderer.setRenderTarget( this.renderTargetMaskDownSampleBuffer );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
this.tempPulseColor1.copy( this.visibleEdgeColor ); this.tempPulseColor1.copy( this.visibleEdgeColor );
this.tempPulseColor2.copy( this.hiddenEdgeColor ); this.tempPulseColor2.copy( this.hiddenEdgeColor );
...@@ -315,44 +315,44 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -315,44 +315,44 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
} }
// 3. Apply Edge Detection Pass // 3. Apply Edge Detection Pass
this.fillQuad.quad.material = this.edgeDetectionMaterial; this.fsQuad.material = this.edgeDetectionMaterial;
this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture; this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture;
this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new THREE.Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height ); this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new THREE.Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height );
this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1; this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1;
this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2; this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2;
renderer.setRenderTarget( this.renderTargetEdgeBuffer1 ); renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// 4. Apply Blur on Half res // 4. Apply Blur on Half res
this.fillQuad.quad.material = this.separableBlurMaterial1; this.fsQuad.material = this.separableBlurMaterial1;
this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture; this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX; this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX;
this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = this.edgeThickness; this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = this.edgeThickness;
renderer.setRenderTarget( this.renderTargetBlurBuffer1 ); renderer.setRenderTarget( this.renderTargetBlurBuffer1 );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer1.texture; this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer1.texture;
this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY; this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY;
renderer.setRenderTarget( this.renderTargetEdgeBuffer1 ); renderer.setRenderTarget( this.renderTargetEdgeBuffer1 );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// Apply Blur on quarter res // Apply Blur on quarter res
this.fillQuad.quad.material = this.separableBlurMaterial2; this.fsQuad.material = this.separableBlurMaterial2;
this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture; this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture;
this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX; this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX;
renderer.setRenderTarget( this.renderTargetBlurBuffer2 ); renderer.setRenderTarget( this.renderTargetBlurBuffer2 );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer2.texture; this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer2.texture;
this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY; this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY;
renderer.setRenderTarget( this.renderTargetEdgeBuffer2 ); renderer.setRenderTarget( this.renderTargetEdgeBuffer2 );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// Blend it additively over the input texture // Blend it additively over the input texture
this.fillQuad.quad.material = this.overlayMaterial; this.fsQuad.material = this.overlayMaterial;
this.overlayMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskBuffer.texture; this.overlayMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskBuffer.texture;
this.overlayMaterial.uniforms[ "edgeTexture1" ].value = this.renderTargetEdgeBuffer1.texture; this.overlayMaterial.uniforms[ "edgeTexture1" ].value = this.renderTargetEdgeBuffer1.texture;
this.overlayMaterial.uniforms[ "edgeTexture2" ].value = this.renderTargetEdgeBuffer2.texture; this.overlayMaterial.uniforms[ "edgeTexture2" ].value = this.renderTargetEdgeBuffer2.texture;
...@@ -365,7 +365,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -365,7 +365,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
renderer.setRenderTarget( readBuffer ); renderer.setRenderTarget( readBuffer );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
renderer.autoClear = oldAutoClear; renderer.autoClear = oldAutoClear;
...@@ -374,10 +374,10 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -374,10 +374,10 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
this.fillQuad.quad.material = this.materialCopy; this.fsQuad.material = this.materialCopy;
this.copyUniforms[ "tDiffuse" ].value = readBuffer.texture; this.copyUniforms[ "tDiffuse" ].value = readBuffer.texture;
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -160,7 +160,7 @@ THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) ...@@ -160,7 +160,7 @@ THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution )
blending: THREE.NoBlending blending: THREE.NoBlending
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -328,8 +328,8 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), ...@@ -328,8 +328,8 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
} }
this.fillQuad.quad.material = passMaterial; this.fsQuad.material = passMaterial;
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// restore original state // restore original state
renderer.autoClear = originalAutoClear; renderer.autoClear = originalAutoClear;
......
...@@ -109,7 +109,7 @@ THREE.SMAAPass = function ( width, height ) { ...@@ -109,7 +109,7 @@ THREE.SMAAPass = function ( width, height ) {
this.needsSwap = false; this.needsSwap = false;
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -123,36 +123,36 @@ THREE.SMAAPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), ...@@ -123,36 +123,36 @@ THREE.SMAAPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
this.uniformsEdges[ "tDiffuse" ].value = readBuffer.texture; this.uniformsEdges[ "tDiffuse" ].value = readBuffer.texture;
this.fillQuad.quad.material = this.materialEdges; this.fsQuad.material = this.materialEdges;
renderer.setRenderTarget( this.edgesRT ); renderer.setRenderTarget( this.edgesRT );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// pass 2 // pass 2
this.fillQuad.quad.material = this.materialWeights; this.fsQuad.material = this.materialWeights;
renderer.setRenderTarget( this.weightsRT ); renderer.setRenderTarget( this.weightsRT );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// pass 3 // pass 3
this.uniformsBlend[ "tColor" ].value = readBuffer.texture; this.uniformsBlend[ "tColor" ].value = readBuffer.texture;
this.fillQuad.quad.material = this.materialBlend; this.fsQuad.material = this.materialBlend;
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -40,7 +40,7 @@ THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) { ...@@ -40,7 +40,7 @@ THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
depthWrite: false depthWrite: false
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( this.copyMaterial ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.copyMaterial );
}; };
...@@ -129,7 +129,7 @@ THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -129,7 +129,7 @@ THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.protot
} }
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -134,7 +134,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) { ...@@ -134,7 +134,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
blendEquationAlpha: THREE.AddEquation blendEquationAlpha: THREE.AddEquation
} ); } );
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
this.originalClearColor = new THREE.Color(); this.originalClearColor = new THREE.Color();
...@@ -269,8 +269,8 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), ...@@ -269,8 +269,8 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
} }
this.fillQuad.quad.material = passMaterial; this.fsQuad.material = passMaterial;
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// restore original state // restore original state
renderer.autoClear = originalAutoClear; renderer.autoClear = originalAutoClear;
......
...@@ -34,7 +34,7 @@ THREE.SavePass = function ( renderTarget ) { ...@@ -34,7 +34,7 @@ THREE.SavePass = function ( renderTarget ) {
this.needsSwap = false; this.needsSwap = false;
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
}; };
...@@ -52,7 +52,7 @@ THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), ...@@ -52,7 +52,7 @@ THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
renderer.setRenderTarget( this.renderTarget ); renderer.setRenderTarget( this.renderTarget );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -29,7 +29,7 @@ THREE.ShaderPass = function ( shader, textureID ) { ...@@ -29,7 +29,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
} }
this.fillQuad = THREE.Pass.createFillQuadScene( this.material ); this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
}; };
THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
...@@ -44,19 +44,19 @@ THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -44,19 +44,19 @@ THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
} }
this.fillQuad.quad.material = this.material; this.fsQuad.material = this.material;
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600 // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil ); if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -99,7 +99,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa ...@@ -99,7 +99,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa
renderer.setRenderTarget( this.sampleRenderTarget ); renderer.setRenderTarget( this.sampleRenderTarget );
if ( this.accumulateIndex === 0 ) renderer.clear(); if ( this.accumulateIndex === 0 ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
this.accumulateIndex ++; this.accumulateIndex ++;
...@@ -119,7 +119,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa ...@@ -119,7 +119,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa
this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture; this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture;
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
...@@ -129,7 +129,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa ...@@ -129,7 +129,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa
this.copyUniforms[ "tDiffuse" ].value = this.holdRenderTarget.texture; this.copyUniforms[ "tDiffuse" ].value = this.holdRenderTarget.texture;
renderer.setRenderTarget( writeBuffer ); renderer.setRenderTarget( writeBuffer );
if ( accumulationWeight === 0 ) renderer.clear(); if ( accumulationWeight === 0 ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
...@@ -28,7 +28,7 @@ THREE.TexturePass = function ( map, opacity ) { ...@@ -28,7 +28,7 @@ THREE.TexturePass = function ( map, opacity ) {
this.needsSwap = false; this.needsSwap = false;
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -41,7 +41,7 @@ THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -41,7 +41,7 @@ THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
var oldAutoClear = renderer.autoClear; var oldAutoClear = renderer.autoClear;
renderer.autoClear = false; renderer.autoClear = false;
this.fillQuad.quad.material = this.material; this.fsQuad.material = this.material;
this.uniforms[ "opacity" ].value = this.opacity; this.uniforms[ "opacity" ].value = this.opacity;
this.uniforms[ "tDiffuse" ].value = this.map; this.uniforms[ "tDiffuse" ].value = this.map;
...@@ -49,7 +49,7 @@ THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ...@@ -49,7 +49,7 @@ THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
renderer.setRenderTarget( this.renderToScreen ? null : readBuffer ); renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
renderer.autoClear = oldAutoClear; renderer.autoClear = oldAutoClear;
} }
......
...@@ -133,7 +133,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) { ...@@ -133,7 +133,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) {
this.basic = new THREE.MeshBasicMaterial(); this.basic = new THREE.MeshBasicMaterial();
this.fillQuad = THREE.Pass.createFillQuadScene( null ); this.fsQuad = new THREE.Pass.FullScreenQuad( null );
}; };
...@@ -195,12 +195,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto ...@@ -195,12 +195,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
this.fillQuad.quad.material = this.basic; this.fsQuad.material = this.basic;
this.basic.map = readBuffer.texture; this.basic.map = readBuffer.texture;
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
...@@ -208,11 +208,11 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto ...@@ -208,11 +208,11 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
this.highPassUniforms[ "tDiffuse" ].value = readBuffer.texture; this.highPassUniforms[ "tDiffuse" ].value = readBuffer.texture;
this.highPassUniforms[ "luminosityThreshold" ].value = this.threshold; this.highPassUniforms[ "luminosityThreshold" ].value = this.threshold;
this.fillQuad.quad.material = this.materialHighPassFilter; this.fsQuad.material = this.materialHighPassFilter;
renderer.setRenderTarget( this.renderTargetBright ); renderer.setRenderTarget( this.renderTargetBright );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// 2. Blur All the mips progressively // 2. Blur All the mips progressively
...@@ -220,19 +220,19 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto ...@@ -220,19 +220,19 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
for ( var i = 0; i < this.nMips; i ++ ) { for ( var i = 0; i < this.nMips; i ++ ) {
this.fillQuad.quad.material = this.separableBlurMaterials[ i ]; this.fsQuad.material = this.separableBlurMaterials[ i ];
this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = inputRenderTarget.texture; this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = inputRenderTarget.texture;
this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionX; this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionX;
renderer.setRenderTarget( this.renderTargetsHorizontal[ i ] ); renderer.setRenderTarget( this.renderTargetsHorizontal[ i ] );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = this.renderTargetsHorizontal[ i ].texture; this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = this.renderTargetsHorizontal[ i ].texture;
this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionY; this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionY;
renderer.setRenderTarget( this.renderTargetsVertical[ i ] ); renderer.setRenderTarget( this.renderTargetsVertical[ i ] );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
inputRenderTarget = this.renderTargetsVertical[ i ]; inputRenderTarget = this.renderTargetsVertical[ i ];
...@@ -240,18 +240,18 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto ...@@ -240,18 +240,18 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
// Composite All the mips // Composite All the mips
this.fillQuad.quad.material = this.compositeMaterial; this.fsQuad.material = this.compositeMaterial;
this.compositeMaterial.uniforms[ "bloomStrength" ].value = this.strength; this.compositeMaterial.uniforms[ "bloomStrength" ].value = this.strength;
this.compositeMaterial.uniforms[ "bloomRadius" ].value = this.radius; this.compositeMaterial.uniforms[ "bloomRadius" ].value = this.radius;
this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors; this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors;
renderer.setRenderTarget( this.renderTargetsHorizontal[ 0 ] ); renderer.setRenderTarget( this.renderTargetsHorizontal[ 0 ] );
renderer.clear(); renderer.clear();
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
// Blend it additively over the input texture // Blend it additively over the input texture
this.fillQuad.quad.material = this.materialCopy; this.fsQuad.material = this.materialCopy;
this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture; this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture;
if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
...@@ -260,12 +260,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto ...@@ -260,12 +260,12 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} else { } else {
renderer.setRenderTarget( readBuffer ); renderer.setRenderTarget( readBuffer );
renderer.render( this.fillQuad.quad, this.fillQuad.camera ); this.fsQuad.render( renderer );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册