playcanvas
Version:
PlayCanvas WebGL game engine
34 lines (32 loc) • 1.02 kB
JavaScript
var aoSpecOccPS = `
uniform material_occludeSpecularIntensity: f32;
fn occludeSpecular(gloss: f32, ao: f32, worldNormal: vec3f, viewDir: vec3f) {
var specOcc: f32 = mix(1.0, ao, uniform.material_occludeSpecularIntensity);
var specOcc: f32 = ao;
var specPow: f32 = exp2(gloss * 11.0);
var specOcc: f32 = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01 * specPow) - 1.0 + ao);
specOcc = mix(1.0, specOcc, uniform.material_occludeSpecularIntensity);
dSpecularLight = dSpecularLight * specOcc;
dReflection = dReflection * specOcc;
sSpecularLight = sSpecularLight * specOcc;
sReflection = sReflection * specOcc;
}
`;
export { aoSpecOccPS as default };