AccessorsUtils.js 1.1 KB

12345678910111213141516171819202122232425
  1. import { bitangentView } from './BitangentNode.js';
  2. import { normalView, transformedNormalView } from './NormalNode.js';
  3. import { tangentView } from './TangentNode.js';
  4. import { mat3 } from '../shadernode/ShaderNode.js';
  5. import { mix } from '../math/MathNode.js';
  6. import { anisotropy, anisotropyB, roughness } from '../core/PropertyNode.js';
  7. import { positionViewDirection } from './PositionNode.js';
  8. export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
  9. export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
  10. export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
  11. export const transformedBentNormalView = ( () => {
  12. // https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
  13. let bentNormal = anisotropyB.cross( positionViewDirection );
  14. bentNormal = bentNormal.cross( anisotropyB ).normalize();
  15. bentNormal = mix( bentNormal, transformedNormalView, anisotropy.mul( roughness.oneMinus() ).oneMinus().pow2().pow2() ).normalize();
  16. return bentNormal;
  17. } )();