@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
17 lines (13 loc) • 553 B
JavaScript
import { PI_RECIPROCAL } from "../../PI_RECIPROCAL.js";
/**
* GGX diffuse distribution function
* @see https://google.github.io/filament/Filament.md.html#listing_diffusebrdf
* @param {number} NoH dot(n,h) where n is surface normal and h is half unit vector between incident light and outgoing light (view vector)
* @param {number} roughness
* @returns {number}
*/
export function diffuse_GGX(NoH, roughness) {
const a = NoH * roughness;
const k = roughness / (1 - NoH * NoH + a * a);
return k * k * PI_RECIPROCAL;
}