ScreenUVNode.js 761 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.ScreenUVNode = function( resolution ) {
  5. THREE.TempNode.call( this, 'v2' );
  6. this.resolution = resolution;
  7. };
  8. THREE.ScreenUVNode.prototype = Object.create( THREE.TempNode.prototype );
  9. THREE.ScreenUVNode.prototype.constructor = THREE.ScreenUVNode;
  10. THREE.ScreenUVNode.prototype.generate = function( builder, output ) {
  11. var material = builder.material;
  12. var result;
  13. if ( builder.isShader( 'fragment' ) ) {
  14. result = '(gl_FragCoord.xy/' + this.resolution.build( builder, 'v2' ) + ')';
  15. }
  16. else {
  17. console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." );
  18. result = 'vec2( 0.0 )';
  19. }
  20. return builder.format( result, this.getType( builder ), output );
  21. };