vertex_shader "varying vec2 texcoord; varying vec3 shadowcoord; varying vec3 normal; varying vec3 cam_dir; void main() { gl_Position = ftransform(); texcoord = gl_MultiTexCoord0.xy; vec4 eye_pos = gl_ModelViewMatrix*gl_Vertex; shadowcoord = vec3(dot(gl_EyePlaneS[3], eye_pos), dot(gl_EyePlaneT[3], eye_pos), dot(gl_EyePlaneR[3], eye_pos)); normal = normalize(gl_NormalMatrix*gl_Normal); cam_dir = -normalize((gl_ModelViewMatrix*gl_Vertex).xyz); }"; fragment_shader "uniform sampler2D texture; uniform sampler2D texattr; uniform sampler2DShadow shadow; varying vec2 texcoord; varying vec3 shadowcoord; varying vec3 normal; varying vec3 cam_dir; void main() { vec3 color = texture2D(texture, texcoord).rgb; vec3 attr = texture2D(texattr, texcoord).rgb*vec3(4.0, 128.0, 64.0); vec3 nnorm = normalize(normal); float shade = shadow2D(shadow, shadowcoord).r; float diffuse = 0.3+max(dot(gl_LightSource[0].position.xyz, nnorm), 0.0)*0.7*shade; vec3 half_vec = normalize(cam_dir+gl_LightSource[0].position.xyz); float specular = pow(max(dot(nnorm, half_vec), 0.0), attr.g)*shade; gl_FragColor = vec4((diffuse+specular*attr.r+attr.b)*color, 1.0); }";