topical media & game development

talk show tell print

mobile-query-three-vendor-three.js-postprocessing-RenderPass.js / js



  

author: alteredq / alteredqualia.com/

  
  
  THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
  
          this.scene = scene;
          this.camera = camera;
  
          this.overrideMaterial = overrideMaterial;
  
          this.clearColor = clearColor;
          this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
  
          this.oldClearColor = new THREE.Color();
          this.oldClearAlpha = 1;
  
          this.enabled = true;
          this.clear = true;
          this.needsSwap = false;
  
  };
  
  THREE.RenderPass.prototype = {
  
          render: function ( renderer, writeBuffer, readBuffer, delta ) {
  
                  this.scene.overrideMaterial = this.overrideMaterial;
  
                  if ( this.clearColor ) {
  
                          this.oldClearColor.copy( renderer.getClearColor() );
                          this.oldClearAlpha = renderer.getClearAlpha();
  
                          renderer.setClearColor( this.clearColor, this.clearAlpha );
  
                  }
  
                  renderer.render( this.scene, this.camera, readBuffer, this.clear );
  
                  if ( this.clearColor ) {
  
                          renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
  
                  }
  
                  this.scene.overrideMaterial = null;
  
          }
  
  };
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.