--- /dev/null
+uniform mat4 envmap_matrix;
+
+varying vec3 vdir, ldir[3], normal;
+varying vec4 shadow_tc;
+varying vec3 wdir;
+
+void main()
+{
+ gl_Position = ftransform();
+
+ vec3 vpos = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ normal = gl_NormalMatrix * gl_Normal;
+ vdir = -vpos;
+ wdir = (envmap_matrix * vec4(vdir, 1.0)).xyz; // bring back to world space
+ ldir[0] = gl_LightSource[0].position.xyz - vpos;
+ ldir[1] = gl_LightSource[1].position.xyz - vpos;
+ ldir[2] = gl_LightSource[2].position.xyz - vpos;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ mat4 offmat = mat4(0.5, 0.0, 0.0, 0.0,
+ 0.0, 0.5, 0.0, 0.0,
+ 0.0, 0.0, 0.5, 0.0,
+ 0.5, 0.5, 0.5, 1.0);
+ mat4 tex_matrix = offmat * gl_TextureMatrix[1];
+
+ shadow_tc = tex_matrix * vec4(vpos, 1.0);
+}