@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
27 lines (22 loc) • 971 B
JavaScript
import { PI_RECIPROCAL } from "../../PI_RECIPROCAL.js";
import { bsdf_schlick } from "../bsdf/bsdf_schlick.js";
/**
* @see https://google.github.io/filament/Filament.md.html#listing_diffusebrdf
* @see Brent Burley. 2012. Physically Based Shading at Disney. Physically Based Shading in Film and Game Production, ACM SIGGRAPH 2012 Courses.
* N = surface normal
* L = light direction
* V = view direction
* H = normalize( V + L )
*
* @param {number} NoV = abs(dot(n, v)) + 1e-5
* @param {number} NoL = lamp(dot(n, l), 0.0, 1.0)
* @param {number} LoH = clamp(dot(l, h), 0.0, 1.0)
* @param {number} roughness surface roughness coefficient
* @returns {number}
*/
export function brdf_burley(NoV, NoL, LoH, roughness) {
const f90 = 0.5 + 2.0 * roughness * LoH * LoH;
const lightScatter = bsdf_schlick(1.0, f90, NoL);
const viewScatter = bsdf_schlick(1.0, f90, NoV);
return lightScatter * viewScatter * PI_RECIPROCAL;
}