提交 9e399660 编写于 作者: A alteredq

Added ability to disable render passes to EffectComposer. Added simple blend...

Added ability to disable render passes to EffectComposer. Added simple blend shader to ShaderExtras.
上级 00b8d061
......@@ -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 ) {
......
......@@ -51,6 +51,7 @@ THREE.BloomPass = function( strength, kernelSize, sigma, resolution ) {
} );
this.enabled = true;
this.needsSwap = false;
this.clear = false;
......
......@@ -22,6 +22,7 @@ THREE.DotScreenPass = function( center, angle, scale ) {
} );
this.enabled = true;
this.renderToScreen = false;
this.needsSwap = true;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 = {
......
......@@ -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 = {
......
......@@ -17,6 +17,8 @@ THREE.ShaderPass = function( shader, textureID ) {
} );
this.renderToScreen = false;
this.enabled = true;
this.needsSwap = true;
this.clear = false;
......
......@@ -19,6 +19,7 @@ THREE.TexturePass = function( texture, opacity ) {
} );
this.enabled = true;
this.needsSwap = false;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册