F_Schlick.js 629 B

123456789101112131415161718
  1. import { ShaderNode, add, sub, mul, exp2 } from '../../shadernode/ShaderNodeBaseElements.js';
  2. const F_Schlick = new ShaderNode( ( inputs ) => {
  3. const { f0, f90, dotVH } = inputs;
  4. // Original approximation by Christophe Schlick '94
  5. // float fresnel = pow( 1.0 - dotVH, 5.0 );
  6. // Optimized variant (presented by Epic at SIGGRAPH '13)
  7. // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
  8. const fresnel = exp2( mul( sub( mul( - 5.55473, dotVH ), 6.98316 ), dotVH ) );
  9. return add( mul( f0, sub( 1.0, fresnel ) ), mul( f90, fresnel ) );
  10. } ); // validated
  11. export default F_Schlick;