#ifdef BUMP

uniform sampler2DShadow		depthTexture;
uniform sampler2D			currTexture;
uniform sampler2D			bumpTexture;

varying vec3	N, V, L, V_M;
varying vec4	glVertex;
varying vec2  glTexCoord0;
varying vec4	shadowMapTexCoord;

void main(void)
{


  vec2 texCoord = gl_TexCoord[0].st;
// parallax
  float	height_scale = 0.05;
  float height2 = height_scale * (1.0 - texture2D(bumpTexture, texCoord).a);
	texCoord += height2 * V_M.xy;
// \\ parallax

  vec3 n = N;
 // vec3 n = normalize(N+gl_NormalMatrix*texture2D(bumpTexture, texCoord).xyz);

	vec3 R = -normalize(reflect(L, n));
	
	vec4 ambient = gl_FrontLightProduct[0].ambient;
	vec4 diffuse = gl_FrontLightProduct[0].diffuse * max(dot(n, L), 0.0);
	vec4 specular = gl_FrontLightProduct[0].specular * pow(max(dot(R, V), 0.0), gl_FrontMaterial.shininess);
	
	vec3 coord = 0.5 * (shadowMapTexCoord.xyz / shadowMapTexCoord.w + 1.0);

	float shadow = shadow2D(depthTexture, coord).r;
	
	gl_FragColor = ((ambient + (0.5 + 0.5 * shadow) * diffuse) + specular * shadow)*texture2D(currTexture, texCoord);
}

#else

uniform sampler2DShadow		depthTexture;
uniform sampler2D currTexture;

varying vec3		N, V, L;
varying vec4		shadowMapTexCoord;

void main(void)
{
	vec3 R = -normalize(reflect(L, N));
	
	vec4 ambient = gl_FrontLightProduct[0].ambient;
	vec4 diffuse = gl_FrontLightProduct[0].diffuse * max(dot(N, L), 0.0);
	vec4 specular = gl_FrontLightProduct[0].specular * pow(max(dot(R, V), 0.0), gl_FrontMaterial.shininess);
	
  float wInv = 1.0/shadowMapTexCoord.w;
	vec3 coord = 0.5 * (shadowMapTexCoord.xyz*wInv + 1.0);

	float shadow = shadow2D(depthTexture, coord).r;
	gl_FragColor = (ambient + (diffuse + specular)*shadow)*texture2D(currTexture, gl_TexCoord[0].st);

}

#endif