DotScreenPass.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. */
  4. import {
  5. ShaderMaterial,
  6. UniformsUtils
  7. } from "../../../build/three.module.js";
  8. import { Pass } from "../postprocessing/Pass.js";
  9. import { DotScreenShader } from "../shaders/DotScreenShader.js";
  10. var DotScreenPass = function ( center, angle, scale ) {
  11. Pass.call( this );
  12. if ( DotScreenShader === undefined )
  13. console.error( "DotScreenPass relies on DotScreenShader" );
  14. var shader = DotScreenShader;
  15. this.uniforms = UniformsUtils.clone( shader.uniforms );
  16. if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center );
  17. if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle;
  18. if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale;
  19. this.material = new ShaderMaterial( {
  20. uniforms: this.uniforms,
  21. vertexShader: shader.vertexShader,
  22. fragmentShader: shader.fragmentShader
  23. } );
  24. this.fsQuad = new Pass.FullScreenQuad( this.material );
  25. };
  26. DotScreenPass.prototype = Object.assign( Object.create( Pass.prototype ), {
  27. constructor: DotScreenPass,
  28. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  29. this.uniforms[ "tDiffuse" ].value = readBuffer.texture;
  30. this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
  31. if ( this.renderToScreen ) {
  32. renderer.setRenderTarget( null );
  33. this.fsQuad.render( renderer );
  34. } else {
  35. renderer.setRenderTarget( writeBuffer );
  36. if ( this.clear ) renderer.clear();
  37. this.fsQuad.render( renderer );
  38. }
  39. }
  40. } );
  41. export { DotScreenPass };