<commit_before>struct Textures
{
    int hasKd;
    int hasKs;
    int hasNs;
    int hasNormal;
    int hasAlpha;

    sampler2D kd;
    sampler2D ks;
    sampler2D ns;
    sampler2D normal;
    sampler2D alpha;
};

struct Material
{
    vec4 kd;
    vec4 ks;

    float ns;

    Textures tex;
};

struct Attenuation
{
    float constant;
    float linear;
    float quadratic;
};

struct DirectionalLight
{
    vec3 direction;
};

struct PointLight
{
    vec3 position;
    Attenuation attenuation;
};

struct SpotLight
{
    vec3 position;
    vec3 direction;

    Attenuation attenuation;

    float innerAngle;
    float outerAngle;
};

struct Light
{
    int type;
    vec4 color;

    DirectionalLight directional;
    PointLight point;
    SpotLight spot;
};

uniform Material material;
uniform Light light;

uniform int plainRendering;

out vec4 fragColor;

in vec3 gPosition;
in vec3 gNormal;
in vec3 gTexcoord;
in vec3 gEye;
in vec3 gTriDistance;


vec3 getKd()
{
    if (material.tex.hasKd == 1)
    {
        return vec3(texture(material.tex.kd, gTexcoord.xy));
    }
    else
    {
        return material.kd.xyz;
    }
}

vec3 getKs()
{
    if (material.tex.hasKs == 1)
    {
        return vec3(texture(material.tex.ks, gTexcoord.xy));
    }
    else
    {
        return material.ks.xyz;
    }
}

float getNs()
{
    if (material.tex.hasNs == 1)
    {
        return texture(material.tex.ns, gTexcoord.xy).r;
    }

    return material.ns;
}

vec3 getNormal()
{
    float dir = gl_FrontFacing ? 1.0 : -1.0;
    if (material.tex.hasNormal == 1)
    {
        vec3 n = normalize(vec3(texture(material.tex.normal, gTexcoord.xy)));
        n = n * 2 - 1;
        return dir * n;
    }
    else
    {
        return vec3(dir * normalize(gNormal));
    }
}


vec3 blinnPhongInternal(vec3 d, vec3 n)
{
    vec3 direction = normalize(d);
    vec3 normal = normalize(n);

    float diffFactor = dot(normal, -direction);

    vec3 diff = vec3(0);
    vec3 spec = vec3(0);

    if (diffFactor > 0.0)
    {
        diff = diffFactor * light.color.xyz * getKd();

        vec3 vertToEye = normalize(gEye - gPosition);
        vec3 lightReflect = normalize(reflect(-direction, normal));
        float specFactor = dot(vertToEye, lightReflect);

        if (specFactor > 0.0)<commit_msg>minor fixes on shaders<commit_after>struct Textures
{
    int hasKd;
    int hasKs;
    int hasNs;
    int hasNormal;
    int hasAlpha;

    sampler2D kd;
    sampler2D ks;
    sampler2D ns;
    sampler2D normal;
    sampler2D alpha;
};

struct Material
{
    vec4 kd;
    vec4 ks;

    float ns;

    Textures tex;
};

struct Attenuation
{
    float constant;
    float linear;
    float quadratic;
};

struct DirectionalLight
{
    vec3 direction;
};

struct PointLight
{
    vec3 position;
    Attenuation attenuation;
};

struct SpotLight
{
    vec3 position;
    vec3 direction;

    Attenuation attenuation;

    float innerAngle;
    float outerAngle;
};

struct Light
{
    int type;
    vec4 color;

    DirectionalLight directional;
    PointLight point;
    SpotLight spot;
};

uniform Material material;
uniform Light light;

uniform int plainRendering;

out vec4 fragColor;

in vec3 gPosition;
in vec3 gNormal;
in vec3 gTexcoord;
in vec3 gEye;
in vec3 gTriDistance;


vec3 getKd()
{
    if (material.tex.hasKd == 1)
    {
        return vec3(texture(material.tex.kd, gTexcoord.xy));
    }
    else
    {
        return material.kd.xyz;
    }
}

vec3 getKs()
{
    if (material.tex.hasKs == 1)
    {
        return vec3(texture(material.tex.ks, gTexcoord.xy));
    }
    else
    {
        return material.ks.xyz;
    }
}

float getNs()
{
    if (material.tex.hasNs == 1)
    {
        return texture(material.tex.ns, gTexcoord.xy).r;
    }

    return material.ns;
}

vec3 getNormal()
{
    float dir = gl_FrontFacing ? 1.0 : -1.0;
    if (material.tex.hasNormal == 1)
    {
        vec3 n = normalize(vec3(texture(material.tex.normal, gTexcoord.xy)));
        n = n * 2 - 1;
        return dir * n;
    }
    else
    {
        return vec3(dir * normalize(gNormal));
    }
}


vec3 blinnPhongInternal(vec3 d, vec3 n)
{
    vec3 direction = normalize(d);
    vec3 normal = normalize(n);

    float diffFactor = dot(normal, -direction);

    vec3 diff = vec3(0);
    vec3 spec = vec3(0);

    if (diffFactor > 0.0)
    {
        diff = diffFactor * light.color.xyz * getKd();

        vec3 vertToEye = normalize(gPosition - gEye);
        vec3 lightReflect = normalize(reflect(-direction, normal));
        float specFactor = dot(vertToEye, lightReflect);

        if (specFactor > 0.0)
{'fraction_non_alphanumeric': 0.10595160235448005, 'fraction_numerical': 0.023108785698713757, 'mean_word_length': 2.348905109489051, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2348559', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1605, 'n_words': 404}