D_GGX.js 573 B

123456789101112131415161718
  1. import { ShaderNode } from '../../shadernode/ShaderNode.js';
  2. // Microfacet Models for Refraction through Rough Surfaces - equation (33)
  3. // http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
  4. // alpha is "roughness squared" in Disney’s reparameterization
  5. const D_GGX = new ShaderNode( ( inputs ) => {
  6. const { alpha, dotNH } = inputs;
  7. const a2 = alpha.pow2();
  8. const denom = dotNH.pow2().mul( a2.oneMinus() ).oneMinus(); // avoid alpha = 0 with dotNH = 1
  9. return a2.div( denom.pow2() ).mul( 1 / Math.PI );
  10. } ); // validated
  11. export default D_GGX;