shadows, textures, resource managers... shaders...
[antikythera] / sdr / shadow.v.glsl
1 uniform mat4 envmap_matrix;
2
3 varying vec3 vdir, ldir[3], normal;
4 varying vec4 shadow_tc;
5 varying vec3 wdir;
6
7 void main()
8 {
9         gl_Position = ftransform();
10
11         vec3 vpos = (gl_ModelViewMatrix * gl_Vertex).xyz;
12         normal = gl_NormalMatrix * gl_Normal;
13         vdir = -vpos;
14         wdir = (envmap_matrix * vec4(vdir, 1.0)).xyz;   // bring back to world space
15         ldir[0] = gl_LightSource[0].position.xyz - vpos;
16         ldir[1] = gl_LightSource[1].position.xyz - vpos;
17         ldir[2] = gl_LightSource[2].position.xyz - vpos;
18         gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
19
20         mat4 offmat = mat4(0.5, 0.0, 0.0, 0.0,
21                         0.0, 0.5, 0.0, 0.0,
22                         0.0, 0.0, 0.5, 0.0,
23                         0.5, 0.5, 0.5, 1.0);
24         mat4 tex_matrix = offmat * gl_TextureMatrix[1];
25
26         shadow_tc = tex_matrix * vec4(vpos, 1.0);
27 }