summaryrefslogtreecommitdiffstats
path: root/src/render/shaders/pervertexcolor.frag
blob: a636781c4f4c64fb93ef5912f340286ca568f0d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#version 150 core

// TODO: Replace with a uniform block
uniform vec4 lightPosition;
uniform vec3 lightIntensity;

in vec3 position;
in vec3 normal;
in vec3 color;

out vec4 fragColor;

vec3 adModel( const in vec3 pos, const in vec3 n, const in vec3 col )
{
    // Calculate the vector from the light to the fragment
    vec3 s = normalize( vec3( lightPosition ) - pos );

    // Calculate the diffuse component
    float diffuse = max( dot( s, n ), 0.0 );

    // Combine the ambient and diffuse contributions
    return lightIntensity * ( col + col * diffuse );
}

void main()
{
    fragColor = vec4( adModel( position, normalize( normal ), color ), 1.0 );
}