ShaderPass.js 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. */
  4. THREE.ShaderPass = function ( shader, textureID ) {
  5. this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
  6. this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
  7. this.material = new THREE.ShaderMaterial( {
  8. uniforms: this.uniforms,
  9. vertexShader: shader.vertexShader,
  10. fragmentShader: shader.fragmentShader
  11. } );
  12. this.renderToScreen = false;
  13. this.enabled = true;
  14. this.needsSwap = true;
  15. this.clear = false;
  16. };
  17. THREE.ShaderPass.prototype = {
  18. render: function ( renderer, writeBuffer, readBuffer, delta ) {
  19. if ( this.uniforms[ this.textureID ] ) {
  20. this.uniforms[ this.textureID ].value = readBuffer;
  21. }
  22. THREE.EffectComposer.quad.material = this.material;
  23. if ( this.renderToScreen ) {
  24. renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
  25. } else {
  26. renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, this.clear );
  27. }
  28. }
  29. };