NodeRoughnessToBlinnExponent.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.NodeRoughnessToBlinnExponent = function() {
  5. THREE.NodeTemp.call( this, 'fv1', {unique:true} );
  6. };
  7. THREE.NodeRoughnessToBlinnExponent.prototype = Object.create( THREE.NodeTemp.prototype );
  8. THREE.NodeRoughnessToBlinnExponent.prototype.constructor = THREE.NodeRoughnessToBlinnExponent;
  9. THREE.NodeRoughnessToBlinnExponent.prototype.generate = function( builder, output ) {
  10. var material = builder.material;
  11. if (builder.isShader('fragment')) {
  12. if (material.isDefined('STANDARD')) {
  13. material.addFragmentNode('float specularMIPLevel = GGXRoughnessToBlinnExponent( 1.0 - material.specularRoughness );');
  14. }
  15. else {
  16. console.warn("THREE.NodeRoughnessToBlinnExponent is compatible with StandardMaterial only");
  17. material.addFragmentNode('float specularMIPLevel = 0.0;');
  18. }
  19. return builder.format( 'specularMIPLevel', this.type, output );
  20. }
  21. else {
  22. console.warn("THREE.NodeRoughnessToBlinnExponent is not compatible with " + builder.shader + " shader");
  23. return builder.format( '0.0', this.type, output );
  24. }
  25. };