MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/snap.cafsinfotech.in/node_modules/mapbox-gl/src/shaders/_prelude_lighting.glsl
#ifdef LIGHTING_3D_MODE

uniform mediump vec3 u_lighting_ambient_color;
uniform mediump vec3 u_lighting_directional_dir;        // Direction towards the light source
uniform mediump vec3 u_lighting_directional_color;

vec3 apply_lighting(vec3 color) {
    float NdotL = u_lighting_directional_dir.z;
    return color * (u_lighting_ambient_color + u_lighting_directional_color * NdotL);
}

vec4 apply_lighting(vec4 color) {
    return vec4(apply_lighting(color.rgb), color.a);
}

float calculate_NdotL(vec3 normal) {
    // Use slightly modified dot product for lambertian diffuse shading. This increase the range of NdotL to cover surfaces facing up to 45 degrees away from the light source.
    // This allows us to trade some realism for performance/usability as a single light source is enough to shade the scene.
    const float ext = 0.70710678118; // acos(pi/4)
    return (clamp(dot(normal, u_lighting_directional_dir), -ext, 1.0) + ext) / (1.0 + ext);
}

vec3 apply_lighting(vec3 color, float NdotL) {
    return color * (u_lighting_ambient_color + u_lighting_directional_color * NdotL);
}

vec4 apply_lighting(vec4 color, float NdotL) {
    return vec4(apply_lighting(color.rgb, NdotL), color.a);
}

#endif