UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

3 lines (2 loc) 893 B
declare const _default: "\n\nfn sheenD(normal: vec3f, h: vec3f, roughness: f32) -> f32 {\n let PI: f32 = 3.141592653589793;\n let invR: f32 = 1.0 / (roughness * roughness);\n var cos2h: f32 = max(dot(normal, h), 0.0);\n cos2h = cos2h * cos2h;\n let sin2h: f32 = max(1.0 - cos2h, 0.0078125);\n return (2.0 + invR) * pow(sin2h, invR * 0.5) / (2.0 * PI);\n}\n\nfn sheenV(normal: vec3f, viewDir: vec3f, light: vec3f) -> f32 {\n let NoV: f32 = max(dot(normal, viewDir), 0.000001);\n let NoL: f32 = max(dot(normal, light), 0.000001);\n return 1.0 / (4.0 * (NoL + NoV - NoL * NoV));\n}\n\nfn getLightSpecularSheen(h: vec3f, worldNormal: vec3f, viewDir: vec3f, lightDirNorm: vec3f, sheenGloss: f32) -> f32 {\n let D: f32 = sheenD(worldNormal, h, sheenGloss);\n let V: f32 = sheenV(worldNormal, viewDir, -lightDirNorm);\n return D * V;\n}"; export default _default;