VERTEX
varying vec3 normal;
varying vec3 lightDir;
varying vec2 pos2;


void main()
{
	lightDir = normalize(vec3(1.0,1.0,0.0));
	normal = normalize(gl_NormalMatrix * gl_Normal);


	vec4 p = (gl_TextureMatrix[1] *vec4(1.0,1.0,1.0,1.0) );
	vec4 p2= gl_ModelViewProjectionMatrix  * gl_Vertex;
	vec4 tpos = gl_ModelViewProjectionMatrix * vec4(0,0,0,1);
	pos2 = ((p2.xy/p2.w)-(tpos.xy/tpos.w))*vec2(1.75,-1.3) + p;

 
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = p2; 

}
PIXEL

uniform sampler2D tex, tex1;

varying vec2  pos2;
varying vec3 normal;
varying vec3 lightDir;

varying vec2 vPos;
uniform vec4 basecolor;
void main()
{

	float NdotL = clamp((dot(normal, lightDir) + 0.6)*0.5, 0.0, 1.0);


	vec4 c = texture2D(tex,gl_TexCoord[0].st) ;
	c.x = c.x * NdotL;

	vec4 c2 = texture2D(tex1,pos2);
	float v = c.x;
	float v2 = 1.0 - (c2.x+c2.y+c2.y)/3.0;

	if(v<v2 && v2>0.0 || c.y <0.5)
		gl_FragColor = basecolor * vec4(0.84,0.65,0.62,1.0);
	else
		gl_FragColor = basecolor;
	

	
}
