Cesium-Examples/libs/three/examples/jsm/nodes/functions/BSDF/D_GGX.js
2025-03-19 11:00:22 +08:00

19 lines
559 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { tslFn } from '../../shadernode/ShaderNode.js';
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disneys reparameterization
const D_GGX = tslFn( ( inputs ) => {
const { alpha, dotNH } = inputs;
const a2 = alpha.pow2();
const denom = dotNH.pow2().mul( a2.oneMinus() ).oneMinus(); // avoid alpha = 0 with dotNH = 1
return a2.div( denom.pow2() ).mul( 1 / Math.PI );
} ); // validated
export default D_GGX;