UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

71 lines (67 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _Normal = require("../../accessors/Normal.js"); var _Position = require("../../accessors/Position.js"); var _PropertyNode = require("../../core/PropertyNode.js"); var _TSLBase = require("../../tsl/TSLBase.js"); // https://github.com/google/filament/blob/master/shaders/src/brdf.fs const D_Charlie = /*@__PURE__*/(0, _TSLBase.Fn)(({ roughness, dotNH }) => { const alpha = roughness.pow2(); // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" const invAlpha = (0, _TSLBase.float)(1.0).div(alpha); const cos2h = dotNH.pow2(); const sin2h = cos2h.oneMinus().max(0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 return (0, _TSLBase.float)(2.0).add(invAlpha).mul(sin2h.pow(invAlpha.mul(0.5))).div(2.0 * Math.PI); }).setLayout({ name: 'D_Charlie', type: 'float', inputs: [{ name: 'roughness', type: 'float' }, { name: 'dotNH', type: 'float' }] }); // https://github.com/google/filament/blob/master/shaders/src/brdf.fs const V_Neubelt = /*@__PURE__*/(0, _TSLBase.Fn)(({ dotNV, dotNL }) => { // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" return (0, _TSLBase.float)(1.0).div((0, _TSLBase.float)(4.0).mul(dotNL.add(dotNV).sub(dotNL.mul(dotNV)))); }).setLayout({ name: 'V_Neubelt', type: 'float', inputs: [{ name: 'dotNV', type: 'float' }, { name: 'dotNL', type: 'float' }] }); const BRDF_Sheen = /*@__PURE__*/(0, _TSLBase.Fn)(({ lightDirection }) => { const halfDir = lightDirection.add(_Position.positionViewDirection).normalize(); const dotNL = _Normal.transformedNormalView.dot(lightDirection).clamp(); const dotNV = _Normal.transformedNormalView.dot(_Position.positionViewDirection).clamp(); const dotNH = _Normal.transformedNormalView.dot(halfDir).clamp(); const D = D_Charlie({ roughness: _PropertyNode.sheenRoughness, dotNH }); const V = V_Neubelt({ dotNV, dotNL }); return _PropertyNode.sheen.mul(D).mul(V); }); var _default = exports.default = BRDF_Sheen;