playcanvas
Version:
PlayCanvas WebGL game engine
44 lines (34 loc) • 1.23 kB
JavaScript
var aoSpecOccPS = /* glsl */ `
uniform float material_occludeSpecularIntensity;
void occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) {
float specOcc = mix(1.0, ao, material_occludeSpecularIntensity);
float specOcc = ao;
// approximated specular occlusion from AO
// http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx
float specPow = exp2(gloss * 11.0);
float specOcc = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01 * specPow) - 1.0 + ao);
specOcc = mix(1.0, specOcc, material_occludeSpecularIntensity);
dSpecularLight *= specOcc;
dReflection *= specOcc;
sSpecularLight *= specOcc;
sReflection *= specOcc;
}
`;
export { aoSpecOccPS as default };