PhysicalLightingModel.js 905 B

123456789101112131415161718192021222324252627
  1. import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
  2. import BRDF_GGX from './BSDF/BRDF_GGX.js';
  3. import {
  4. ShaderNode, mul, saturate, dot, transformedNormalView,
  5. diffuseColor, specularColor, roughness
  6. } from '../shadernode/ShaderNodeBaseElements.js';
  7. const RE_Direct_Physical = new ShaderNode( ( inputs ) => {
  8. const { lightDirection, lightColor, reflectedLight } = inputs;
  9. const dotNL = saturate( dot( transformedNormalView, lightDirection ) );
  10. const irradiance = mul( dotNL, lightColor );
  11. reflectedLight.directSpecular.add( mul( irradiance, BRDF_GGX.call( { lightDirection, f0: specularColor, f90: 1, roughness } ) ) );
  12. reflectedLight.directDiffuse.add( mul( irradiance, BRDF_Lambert.call( { diffuseColor: diffuseColor.rgb } ) ) );
  13. } );
  14. const PhysicalLightingModel = new ShaderNode( ( inputs/*, builder*/ ) => {
  15. RE_Direct_Physical.call( inputs );
  16. } );
  17. export default PhysicalLightingModel;