#version 450 core

in vec2 vUv;
in vec3 vNormal;

uniform sampler2D uBaseColorTex;
uniform vec4 uBaseColorFactor;
uniform int uHasTexture;
uniform int uViewMode; // 0 = BaseColor, 1 = Normal

out vec4 FragColor;

void main()
{
    if (uViewMode == 1)
    {
        vec3 n = normalize(vNormal);
        FragColor = vec4(n * 0.5 + 0.5, 1.0);
        return;
    }

    vec4 c = uBaseColorFactor;
    if (uHasTexture != 0)
    c *= texture(uBaseColorTex, vUv);

    FragColor = c;
}