#include "core.fsh"
#include "light.fsh"

in float Pz_f;

in vec3 N_f;
in vec2 UV_f;
flat in mediump vec2 ClampUV_f;
flat in ivec4 Flags;
flat in float height_f;
flat in int nightLightIndex;
in float nightLightIntensity;

uniform float addLight;
uniform float roofColorRatio;
uniform vec3 addLightColor;
uniform vec4 UVOffsets[4];
uniform vec3 colors[7];

uniform float ao_scale;

layout(location = 0) out vec4 fragColor;

void main()
{
    vec3 normal = N_f;
    vec4 Cd_ = vec4(colors[Flags.w], 1.0);
    float ao = 1.0;
    float colorRatio = (Flags.z == 255) ? roofColorRatio : 1.0;
    
    ao = mix(1.0, ao, ao_scale);
    vec3 lightIntensity = CalLightIntensity(normal, ao);
    
    fragColor = vec4(Cd_.rgb * colorRatio * lightIntensity, Cd_.a);
}

