ScreenUVNode.js 760 B

1234567891011121314151617181920212223242526272829303132333435
  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. } else {
  16. console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." );
  17. result = 'vec2( 0.0 )';
  18. }
  19. return builder.format( result, this.getType( builder ), output );
  20. };