playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
48 lines (47 loc) • 1.16 kB
JavaScript
var lightmapAdd_default = `
void addLightMap(
vec3 lightmap,
vec3 dir,
vec3 worldNormal,
vec3 viewDir,
vec3 reflectionDir,
float gloss,
vec3 specularity,
vec3 vertexNormal,
mat3 tbn
vec3 iridescenceFresnel,
float iridescenceIntensity
) {
if (dot(dir, dir) < 0.0001) {
dDiffuseLight += lightmap;
} else {
float vlight = saturate(dot(dir, -vertexNormal));
float flight = saturate(dot(dir, -worldNormal));
float nlight = (flight / max(vlight, 0.01)) * 0.5;
dDiffuseLight += lightmap * nlight * 2.0;
vec3 halfDir = normalize(-dir + viewDir);
vec3 specularLight = lightmap * getLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dir, gloss, tbn);
specularLight *=
getFresnel(dot(viewDir, halfDir),
gloss,
specularity
, iridescenceFresnel,
iridescenceIntensity
);
dSpecularLight += specularLight;
}
dDiffuseLight += lightmap;
}
`;
export {
lightmapAdd_default as default
};