playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
24 lines (23 loc) • 800 B
JavaScript
var lightSheen_default = `
float sheenD(vec3 normal, vec3 h, float roughness) {
const float PI = 3.141592653589793;
float invR = 1.0 / (roughness * roughness);
float cos2h = max(dot(normal, h), 0.0);
cos2h *= cos2h;
float sin2h = max(1.0 - cos2h, 0.0078125);
return (2.0 + invR) * pow(sin2h, invR * 0.5) / (2.0 * PI);
}
float sheenV(vec3 normal, vec3 viewDir, vec3 light) {
float NoV = max(dot(normal, viewDir), 0.000001);
float NoL = max(dot(normal, light), 0.000001);
return 1.0 / (4.0 * (NoL + NoV - NoL * NoV));
}
float getLightSpecularSheen(vec3 h, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float sheenGloss) {
float D = sheenD(worldNormal, h, sheenGloss);
float V = sheenV(worldNormal, viewDir, -lightDirNorm);
return D * V;
}
`;
export {
lightSheen_default as default
};