diff --git a/examples/js/ShaderExtras.js b/examples/js/ShaderExtras.js index a101afe3..e54e8a51 100644 --- a/examples/js/ShaderExtras.js +++ b/examples/js/ShaderExtras.js @@ -16,8 +16,9 @@ * dofmipmap * focus * triangleBlur - * horizontalBlur - * verticalBlur + * horizontalBlur + verticalBlur + * horizontalTiltShift + verticalTiltShift + * blend */ THREE.ShaderExtras = { @@ -1083,6 +1084,56 @@ THREE.ShaderExtras = { }, + /* ------------------------------------------------------------------------- + // Blend two textures + ------------------------------------------------------------------------- */ + + 'blend': { + + uniforms: { + + tDiffuse1: { type: "t", value: 0, texture: null }, + tDiffuse2: { type: "t", value: 1, texture: null }, + mixRatio: { type: "f", value: 0.5 }, + opacity: { type: "f", value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = vec2( uv.x, 1.0 - uv.y );", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "uniform float opacity;", + "uniform float mixRatio;", + + "uniform sampler2D tDiffuse1;", + "uniform sampler2D tDiffuse2;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel1 = texture2D( tDiffuse1, vUv );", + "vec4 texel2 = texture2D( tDiffuse2, vUv );", + "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );", + + "}" + + ].join("\n") + + }, + // METHODS buildKernel: function( sigma ) { diff --git a/examples/js/postprocessing/BloomPass.js b/examples/js/postprocessing/BloomPass.js index 20689977..ef4e5d05 100644 --- a/examples/js/postprocessing/BloomPass.js +++ b/examples/js/postprocessing/BloomPass.js @@ -51,6 +51,7 @@ THREE.BloomPass = function( strength, kernelSize, sigma, resolution ) { } ); + this.enabled = true; this.needsSwap = false; this.clear = false; diff --git a/examples/js/postprocessing/DotScreenPass.js b/examples/js/postprocessing/DotScreenPass.js index ebaf2720..e945955c 100644 --- a/examples/js/postprocessing/DotScreenPass.js +++ b/examples/js/postprocessing/DotScreenPass.js @@ -22,6 +22,7 @@ THREE.DotScreenPass = function( center, angle, scale ) { } ); + this.enabled = true; this.renderToScreen = false; this.needsSwap = true; diff --git a/examples/js/postprocessing/EffectComposer.js b/examples/js/postprocessing/EffectComposer.js index fbcb0a2a..871bc442 100644 --- a/examples/js/postprocessing/EffectComposer.js +++ b/examples/js/postprocessing/EffectComposer.js @@ -49,13 +49,17 @@ THREE.EffectComposer.prototype = { var maskActive = false; - var i, il = this.passes.length; + var pass, i, il = this.passes.length; for ( i = 0; i < il; i ++ ) { - this.passes[ i ].render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive ); + pass = this.passes[ i ]; - if ( this.passes[ i ].needsSwap ) { + if ( !pass.enabled ) continue; + + pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive ); + + if ( pass.needsSwap ) { if ( maskActive ) { @@ -73,13 +77,11 @@ THREE.EffectComposer.prototype = { } - if ( this.passes[ i ] instanceof THREE.MaskPass ) { + if ( pass instanceof THREE.MaskPass ) { maskActive = true; - } - - if ( this.passes[ i ] instanceof THREE.ClearMaskPass ) { + } else if ( pass instanceof THREE.ClearMaskPass ) { maskActive = false; diff --git a/examples/js/postprocessing/FilmPass.js b/examples/js/postprocessing/FilmPass.js index d0e9634b..3575d2bd 100644 --- a/examples/js/postprocessing/FilmPass.js +++ b/examples/js/postprocessing/FilmPass.js @@ -21,6 +21,7 @@ THREE.FilmPass = function( noiseIntensity, scanlinesIntensity, scanlinesCount, g if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; + this.enabled = true; this.renderToScreen = false; this.needsSwap = true; diff --git a/examples/js/postprocessing/MaskPass.js b/examples/js/postprocessing/MaskPass.js index 0d692bc9..21ab96e9 100644 --- a/examples/js/postprocessing/MaskPass.js +++ b/examples/js/postprocessing/MaskPass.js @@ -7,6 +7,7 @@ THREE.MaskPass = function ( scene, camera ) { this.scene = scene; this.camera = camera; + this.enabled = true; this.clear = true; this.needsSwap = false; @@ -51,6 +52,8 @@ THREE.MaskPass.prototype = { THREE.ClearMaskPass = function () { + this.enabled = true; + }; THREE.ClearMaskPass.prototype = { diff --git a/examples/js/postprocessing/RenderPass.js b/examples/js/postprocessing/RenderPass.js index 6672eb40..0dcc13fe 100644 --- a/examples/js/postprocessing/RenderPass.js +++ b/examples/js/postprocessing/RenderPass.js @@ -12,12 +12,13 @@ THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clear this.clearColor = clearColor; this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1; - this.clear = true; - this.needsSwap = false; - this.oldClearColor = new THREE.Color(); this.oldClearAlpha = 1; + this.enabled = true; + this.clear = true; + this.needsSwap = false; + }; THREE.RenderPass.prototype = { diff --git a/examples/js/postprocessing/ShaderPass.js b/examples/js/postprocessing/ShaderPass.js index a144c23b..1c173e84 100644 --- a/examples/js/postprocessing/ShaderPass.js +++ b/examples/js/postprocessing/ShaderPass.js @@ -17,6 +17,8 @@ THREE.ShaderPass = function( shader, textureID ) { } ); this.renderToScreen = false; + + this.enabled = true; this.needsSwap = true; this.clear = false; diff --git a/examples/js/postprocessing/TexturePass.js b/examples/js/postprocessing/TexturePass.js index c298e49a..ea5d8ac6 100644 --- a/examples/js/postprocessing/TexturePass.js +++ b/examples/js/postprocessing/TexturePass.js @@ -19,6 +19,7 @@ THREE.TexturePass = function( texture, opacity ) { } ); + this.enabled = true; this.needsSwap = false; };