www.pudn.com > AndreasHalm-src.zip > cube.vertexshader


// light vector, set by app 
uniform vec4 light; 
 
varying vec4 Cd;    // diffuse color 
varying vec4 V_eye; // vertex position in eye coordinates 
varying vec4 L_eye; // light vector in eye coordinates 
varying vec4 N_eye; // normal vector in eye coordinates 
varying vec3 eyespace_position; 
 
// a vector in s direction (compared to tex0) 
attribute vec4 tex0_s; 
// a vector in t direction (compared to tex0) 
attribute vec4 tex0_t; 
 
// the vectors above "modelviewed" 
varying vec4 tex0_s_eye; 
varying vec4 tex0_t_eye; 
 
void main(void) 
{ 
  V_eye = gl_ModelViewMatrix * gl_Vertex; 
  L_eye = light - V_eye; 
  N_eye = vec4(gl_NormalMatrix * gl_Normal, 1.0); 
  gl_Position = gl_ProjectionMatrix * V_eye; 
  V_eye = -V_eye; 
  Cd = gl_Color; 
  gl_TexCoord[0] = gl_MultiTexCoord0; 
  eyespace_position = vec3(V_eye) / V_eye.w; 
  tex0_s_eye = vec4(gl_NormalMatrix*vec3(tex0_s),1.0); 
  tex0_t_eye = vec4(gl_NormalMatrix*vec3(tex0_t),1.0); 
}