LambertLightingModel.js 935 B

123456789101112131415161718192021222324
  1. import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
  2. import { lightingModel } from '../core/LightingModel.js';
  3. import { diffuseColor } from '../core/PropertyNode.js';
  4. import { transformedNormalView } from '../accessors/NormalNode.js';
  5. import { tslFn } from '../shadernode/ShaderNode.js';
  6. const RE_Direct_Lambert = tslFn( ( { lightDirection, lightColor, reflectedLight } ) => {
  7. const dotNL = transformedNormalView.dot( lightDirection ).clamp();
  8. const irradiance = dotNL.mul( lightColor );
  9. reflectedLight.directDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) );
  10. } );
  11. const RE_IndirectDiffuse_Lambert = tslFn( ( { irradiance, reflectedLight } ) => {
  12. reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
  13. } );
  14. const lambertLightingModel = lightingModel( null, RE_Direct_Lambert, RE_IndirectDiffuse_Lambert );
  15. export default lambertLightingModel;