Debian Codegraph @

Shaders/ws30.vert

raw
1 // WS30 VERTEX SHADER. Very basic
2 // -*-C++-*-
3 #version 120
4
5 // Shader that uses OpenGL state values to do per-pixel lighting
6 //
7 // The only light used is gl_LightSource[0], which is assumed to be
8 // directional.
9 //
10 // Colors are not assigned in this shader, as they will come from
11 // the landclass lookup in the fragment shader.
12
13
14 #define MODE_OFF 0
15 #define MODE_DIFFUSE 1
16 #define MODE_AMBIENT_AND_DIFFUSE 2
17
18
19 // The constant term of the lighting equation that doesn't depend on
20 // the surface normal is passed in gl_{Front,Back}Color. The alpha
21 // component is set to 1 for front, 0 for back in order to work around
22 // bugs with gl_FrontFacing in the fragment shader.
23 varying vec3 normal;
24 varying vec4 ecPosition;
25
26 // See Shaders/shadows-include.vert
27 void setupShadows(vec4 eyeSpacePos);
28
29 void main()
30 {
31 gl_Position = ftransform();
32 ecPosition = gl_ModelViewMatrix * gl_Vertex;
33
34 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
35 normal = gl_NormalMatrix * gl_Normal;
36
37 // Another hack for supporting two-sided lighting without using
38 // gl_FrontFacing in the fragment shader.
39 gl_FrontColor.a = 1.0;
40 gl_BackColor.a = 0.0;
41 setupShadows(ecPosition);
42 }
43
44
45
46