playcanvas
Version:
PlayCanvas WebGL game engine
4 lines (2 loc) • 1.41 kB
JavaScript
var ambientPS = '\n\n#ifdef LIT_AMBIENT_SOURCE == AMBIENTSH\n uniform vec3 ambientSH[9];\n#endif\n\n#if LIT_AMBIENT_SOURCE == ENVALATLAS\n #include "envAtlasPS"\n\n #ifndef ENV_ATLAS\n #define ENV_ATLAS\n uniform sampler2D texture_envAtlas;\n #endif\n#endif\n\nvoid addAmbient(vec3 worldNormal) {\n #ifdef LIT_AMBIENT_SOURCE == AMBIENTSH\n\n vec3 n = cubeMapRotate(worldNormal);\n vec3 color =\n ambientSH[0] +\n ambientSH[1] * n.x +\n ambientSH[2] * n.y +\n ambientSH[3] * n.z +\n ambientSH[4] * n.x * n.z +\n ambientSH[5] * n.z * n.y +\n ambientSH[6] * n.y * n.x +\n ambientSH[7] * (3.0 * n.z * n.z - 1.0) +\n ambientSH[8] * (n.x * n.x - n.y * n.y);\n\n dDiffuseLight += processEnvironment(max(color, vec3(0.0)));\n\n #endif\n\n #if LIT_AMBIENT_SOURCE == ENVALATLAS\n\n vec3 dir = normalize(cubeMapRotate(worldNormal) * vec3(-1.0, 1.0, 1.0));\n vec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\n vec4 raw = texture2D(texture_envAtlas, uv);\n vec3 linear = {ambientDecode}(raw);\n dDiffuseLight += processEnvironment(linear);\n\n #endif\n\n #if LIT_AMBIENT_SOURCE == CONSTANT\n\n dDiffuseLight += light_globalAmbient;\n\n #endif\n}\n';
export { ambientPS as default };