attribute vec3 position;
attribute vec3 normal;
attribute vec2 texcoord;

uniform mat4 MVP;
uniform mat3 N;
uniform highp vec4 size;
UNIFORMS

varying lowp float FS_diffuse;
varying lowp vec2 FS_texcoord;
VARYINGS

void main(void)
{
    vec3 nor = N*normal;
    vec4 pos = MVP*vec4(position, 1.);

    SET_SHADOW
    SET_AMBIENT_OCCL2

    FS_diffuse = max(dot(LIGHT, nor)*_DIFFUSE, 0.);

    if (normal.z == 1.0)
        FS_texcoord = texcoord*size.xy*.5 - vec2(size.x/4., size.y/4.);
    else
        FS_texcoord = texcoord;
    //FS_texcoord = texcoord*vec2(size.x * (normal.z+abs(normal.y)), size.y * (normal.z+abs(normal.x)));
    gl_Position = pos;
}

