ubershaders and path stripping in metascene
[ld37_one_room] / sdr / uber.v.glsl
1 varying vec3 vpos, vdir, normal;
2 #ifdef USE_SHADOWMAP
3 varying vec4 shadow_tc;
4 #endif
5 #ifdef USE_CUBEMAP
6 varying vec3 wdir;
7 uniform mat4 envmap_matrix;
8 #endif
9
10 void main()
11 {
12         gl_Position = ftransform();
13
14         vpos = (gl_ModelViewMatrix * gl_Vertex).xyz;
15         normal = gl_NormalMatrix * gl_Normal;
16         vdir = -vpos;
17 #ifdef USE_CUBEMAP
18         wdir = (envmap_matrix * vec4(vdir, 1.0)).xyz;   // bring back to world space
19 #endif
20 #ifdef USE_TEXMAP
21         gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
22 #endif
23
24 #ifdef USE_SHADOWMAP
25         mat4 offmat = mat4(0.5, 0.0, 0.0, 0.0,
26                         0.0, 0.5, 0.0, 0.0,
27                         0.0, 0.0, 0.5, 0.0,
28                         0.5, 0.5, 0.5, 1.0);
29         mat4 tex_matrix = offmat * gl_TextureMatrix[1];
30
31         shadow_tc = tex_matrix * vec4(vpos, 1.0);
32 #endif
33 }