diff --git a/examples/js/postprocessing/EffectComposer.js b/examples/js/postprocessing/EffectComposer.js
index 28d2bfa68d5a3ca02fab369b8800327a01e21245..ef540e856a03b3fa77a43cdd0306f37df7bdbb0d 100644
--- a/examples/js/postprocessing/EffectComposer.js
+++ b/examples/js/postprocessing/EffectComposer.js
@@ -47,6 +47,12 @@ THREE.EffectComposer.prototype = {
},
+ insertPass: function ( pass, index ) {
+
+ this.passes.splice( index, 0, pass );
+
+ },
+
render: function ( delta ) {
this.writeBuffer = this.renderTarget1;
diff --git a/examples/js/renderers/WebGLDeferredRenderer.js b/examples/js/renderers/WebGLDeferredRenderer.js
index 94ab05142bcf3ffcfc447e8f79f3ebcc66651a4f..de26b24c5aae85c81c0c54c48a060fdd96235d2d 100644
--- a/examples/js/renderers/WebGLDeferredRenderer.js
+++ b/examples/js/renderers/WebGLDeferredRenderer.js
@@ -205,7 +205,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms.viewWidth.value = scaledWidth;
uniforms.viewHeight.value = scaledHeight;
- resizableMaterials.push( material );
+ resizableMaterials.push( { "material": material } );
}
@@ -402,7 +402,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
// sync proxy uniforms to the original light
@@ -478,7 +478,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
// sync proxy uniforms to the original light
@@ -544,7 +544,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
// sync proxy uniforms to the original light
@@ -610,7 +610,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
// sync proxy uniforms to the original light
@@ -698,7 +698,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
// sync proxy uniforms to the original light
@@ -734,7 +734,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
// keep reference for size reset
- resizableMaterials.push( materialLight );
+ resizableMaterials.push( { "material": materialLight } );
return meshLight;
@@ -849,6 +849,25 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
};
+ this.addEffect = function ( effect, normalDepthUniform, colorUniform ) {
+
+ if ( effect.material && effect.uniforms ) {
+
+ if ( normalDepthUniform ) effect.uniforms[ normalDepthUniform ].value = compNormalDepth.renderTarget2;
+ if ( colorUniform ) effect.uniforms[ colorUniform ].value = compColor.renderTarget2;
+
+ if ( normalDepthUniform || colorUniform ) {
+
+ resizableMaterials.push( { "material": effect.material, "normalDepth": normalDepthUniform, "color": colorUniform } );
+
+ }
+
+ }
+
+ compFinal.insertPass( effect, -1 );
+
+ };
+
this.setScale = function ( scale ) {
currentScale = scale;
@@ -866,13 +885,19 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
for ( var i = 0, il = resizableMaterials.length; i < il; i ++ ) {
- var uniforms = resizableMaterials[ i ].uniforms;
+ var materialEntry = resizableMaterials[ i ];
+
+ var material = materialEntry.material;
+ var uniforms = material.uniforms;
+
+ var colorLabel = materialEntry.color !== undefined ? materialEntry.color : 'samplerColor';
+ var normalDepthLabel = materialEntry.normalDepth !== undefined ? materialEntry.normalDepth : 'samplerNormalDepth';
- uniforms[ "viewWidth" ].value = scaledWidth;
- uniforms[ "viewHeight" ].value = scaledHeight;
+ if ( uniforms[ colorLabel ] ) uniforms[ colorLabel ].value = compColor.renderTarget2;
+ if ( uniforms[ normalDepthLabel ] ) uniforms[ normalDepthLabel ].value = compNormalDepth.renderTarget2;
- if ( uniforms[ 'samplerColor' ] ) uniforms[ 'samplerColor' ].value = compColor.renderTarget2;
- if ( uniforms[ 'samplerNormalDepth' ] ) uniforms[ 'samplerNormalDepth' ].value = compNormalDepth.renderTarget2;
+ if ( uniforms[ 'viewWidth' ] ) uniforms[ "viewWidth" ].value = scaledWidth;
+ if ( uniforms[ 'viewHeight' ] ) uniforms[ "viewHeight" ].value = scaledHeight;
}
diff --git a/examples/webgl_lights_deferred_arealights.html b/examples/webgl_lights_deferred_arealights.html
index 0467c41e30873e1e28a923ce046c3d4edc435070..5195fb9844ddd9238234a621ac20bdc6c6b7a866 100644
--- a/examples/webgl_lights_deferred_arealights.html
+++ b/examples/webgl_lights_deferred_arealights.html
@@ -54,11 +54,13 @@
+
+