#ifdef GL_ES
precision highp float;
#else
#define highp
#define mediump
#define lowp
#endif

#if defined(CONST_COLOR) && !defined(VERTEX_COLOR)
// when "vertex color" not present there is no need to interpolate "const color", send it to pixel shader instead
#undef CONST_COLOR
#endif

// ------- ATTRIBUTES (VERTEX BUFFER DATA) -------
attribute vec4		attrVertex;

#ifdef TEXTURE0
attribute vec4		attrTex0UV;
#endif

#ifdef VERTEX_COLOR
attribute vec4		attrColor;
#endif

// ------- UNIFORMS (SHADER CONSTS) -------
uniform mat4		uniPMVMatrix;

#ifdef GEONORMALMAP
//uniform mat4		uniMVMatrix;
uniform mat4		uniLocalToGeoMatrix;
uniform vec4		uniHeightmapGeo;
#endif

#ifdef TEXTURE0
#ifdef TEXTURE_MATRIX
uniform mat4		uniTextureMatrix;
#endif
#endif

#ifdef CONST_COLOR
uniform	vec4		uniColor;
#endif

#ifdef PRIMITIVE_POINTS
uniform	float		uniPointSize;
#endif

// ------- INTERPOLATORS (SHADER OUTPUTS) -------
#ifdef GEONORMALMAP
//varying vec3		varGeoVertex;
varying vec2		varHeightmapUV;
#endif

#ifdef TEXTURE0
varying vec2		varTex0UV;
#endif

#ifdef VERTEX_COLOR
varying vec4		varColor;
#endif

void main(void)
{
	gl_Position = uniPMVMatrix*attrVertex;

#ifdef GEONORMALMAP
	vec3 vGeoVertex = vec3(uniLocalToGeoMatrix*attrVertex);
	varHeightmapUV = vec2(vGeoVertex.x - uniHeightmapGeo.x, vGeoVertex.z + uniHeightmapGeo.y)*uniHeightmapGeo.z;;
#endif

#ifdef TEXTURE0
#ifdef TEXTURE_MATRIX
	vec4 vTransUV = uniTextureMatrix*attrTex0UV;
	varTex0UV = vTransUV.st;
#else
	varTex0UV = attrTex0UV.st;
#endif
#endif

#ifdef VERTEX_COLOR
	vec4 vColor = attrColor;
#endif

#ifdef CONST_COLOR
	vColor *= uniColor;
#endif

#ifdef VERTEX_COLOR
	varColor = vColor;
#endif

#ifdef PRIMITIVE_POINTS
	gl_PointSize = uniPointSize;
#endif
};