@openhps/core
Version:
Open Hybrid Positioning System - Core component
56 lines (51 loc) • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.transformedBentNormalView = exports.parallaxUV = exports.parallaxDirection = exports.TBNViewMatrix = void 0;
var _Bitangent = require("./Bitangent.js");
var _Normal = require("./Normal.js");
var _Tangent = require("./Tangent.js");
var _TSLBase = require("../tsl/TSLBase.js");
var _MathNode = require("../math/MathNode.js");
var _PropertyNode = require("../core/PropertyNode.js");
var _Position = require("./Position.js");
/**
* TSL object that represents the TBN matrix in view space.
*
* @tsl
* @type {Node<mat3>}
*/
const TBNViewMatrix = exports.TBNViewMatrix = /*@__PURE__*/(0, _TSLBase.mat3)(_Tangent.tangentView, _Bitangent.bitangentView, _Normal.normalView);
/**
* TSL object that represents the parallax direction.
*
* @tsl
* @type {Node<mat3>}
*/
const parallaxDirection = exports.parallaxDirection = /*@__PURE__*/_Position.positionViewDirection.mul(TBNViewMatrix) /*.normalize()*/;
/**
* TSL function for computing parallax uv coordinates.
*
* @tsl
* @function
* @param {Node<vec2>} uv - A uv node.
* @param {Node<vec2>} scale - A scale node.
* @returns {Node<vec2>} Parallax uv coordinates.
*/
const parallaxUV = (uv, scale) => uv.sub(parallaxDirection.mul(scale));
/**
* TSL function for computing bent normals.
*
* @tsl
* @function
* @returns {Node<vec3>} Bent normals.
*/
exports.parallaxUV = parallaxUV;
const transformedBentNormalView = exports.transformedBentNormalView = /*@__PURE__*/(() => {
// https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
let bentNormal = _PropertyNode.anisotropyB.cross(_Position.positionViewDirection);
bentNormal = bentNormal.cross(_PropertyNode.anisotropyB).normalize();
bentNormal = (0, _MathNode.mix)(bentNormal, _Normal.transformedNormalView, _PropertyNode.anisotropy.mul(_PropertyNode.roughness.oneMinus()).oneMinus().pow2().pow2()).normalize();
return bentNormal;
})();