summaryrefslogtreecommitdiffstats
path: root/src/render/shaders/es2/pervertexcolor.frag
blob: e9a6800bb97731c633380cdf53b29e98757db948 (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
#define FP highp

uniform FP vec4 lightPosition;
uniform FP vec3 lightIntensity;

varying FP vec3 position;
varying FP vec3 normal;
varying FP vec3 color;

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

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

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

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