[[vertex]]

uniform mat4 mvp;

in vec4 pos;
in vec3 nor;
in vec2 uvs;
out vec3 n;
out vec2 uv;

void main()
{
    n = nor;
    uv = uvs;
    gl_Position = mvp * pos;
}

[[fragment]]

uniform mediump sampler2D tex;
uniform mediump vec3 light_dir;
uniform mediump float ambient;

in mediump vec3 n;
in mediump vec2 uv;
out mediump vec4 frag;

void main()
{
    mediump float d = max(0.0, dot(normalize(n), normalize(light_dir)));
    mediump vec4 c = texture(tex, uv);
    frag = vec4(c.rgb * d + ambient, 1.0);
}
