#include "core.fsh"
#include "commonInput.fsh"

#ifndef DISL_DISABLE_LIGHT
#include "light.fsh"
#endif

#ifdef DISL_USE_MIX_CD
in float weight_f;
uniform lowp vec4 Cd1;
uniform lowp vec4 Cd2;
#endif

#ifdef DISL_SEP_BACK_CD
uniform lowp vec4 Cd_Back;
#define GET_FACE_CD(Cd_Front) gl_FrontFacing? Cd_Front: Cd_Back
#else
#define GET_FACE_CD(Cd_Front) Cd_Front
#endif

layout(location = 0) out vec4 fragColor;

void main()
{
#ifdef DISL_USE_MIX_CD
    vec4 albedo = GET_FACE_CD(mix(Cd1, Cd2, smoothstep(0.0, 1.0, weight_f)));
#else
    vec4 albedo = GET_FACE_CD(getBaseCol());
#endif
    
#if defined(DISL_DISABLE_LIGHT)
    vec3 lightIntensity = vec3(1.0);
#else
    vec3 lightIntensity = CalLightIntensity(getNormal(), 1.0);
#endif
    
    fragColor = vec4(albedo.rgb * lightIntensity, albedo.a);
}
