<Shader>
	<VertexShader>
		<Code>
			#version 120
			//varying vec2 Texcoord;
			varying vec3 Normal;
			varying vec3 LightDir;
			varying vec3 ViewDir;
	
			uniform mat4 Jen_ModelViewProjectionMatrix;
			uniform vec4 CubePosSize[6];
			uniform vec3 Jen_LightPos;
			uniform vec3 Jen_ViewPos;
			
			attribute vec4 PosIdAttr;
			attribute vec3 NormalAttr;

			void main( void )
			{
				Normal = NormalAttr;
						
				vec4 PosSize = CubePosSize[int(PosIdAttr.w)]; 
				vec3 Pos = PosIdAttr.xyz*PosSize.w+PosSize.xyz;
				
				LightDir = Jen_LightPos - Pos;
				ViewDir = Jen_ViewPos - Pos;
				
				gl_Position = Jen_ModelViewProjectionMatrix * vec4(Pos, 1.0);
			}
		</Code>
	</VertexShader>
	
	<FragmentShader>
		<Code>
			#version 120
			uniform sampler2D NormalMap;
			uniform vec3 Color;

			varying vec3 Normal;
			varying vec3 LightDir;
			varying vec3 ViewDir;
	
			void main( void )
			{
				float LightLength = length(LightDir);
				vec3 nViewDir = normalize(ViewDir);
				vec3 nLightDir = LightDir/LightLength;

				float fRDotV = clamp(dot(reflect(-nLightDir, Normal), nViewDir),0.0, 1.0);
				float fresnel = 1.0 - clamp(abs(dot(nViewDir,Normal)), 0.1, 0.9);
				
				float Ndotl = max(dot(Normal,nLightDir),0.0);
				float Spec = mix(pow(fRDotV, 50.0)*2.8,0.0,min(LightLength*0.014,1.0));
				float Diff = mix(Ndotl,Ndotl*0.28,min(LightLength*0.02,1.0));
				
				gl_FragColor = vec4(Color*(0.2 + Spec*fresnel + Diff),1.0);
			}
		</Code> 
	</FragmentShader>
</Shader>
