scg3  0.6
gouraud_vert.glsl
Go to the documentation of this file.
1 /**
2  * \file gouraud_vert.glsl
3  * \brief Gouraud vertex shader, uses external function applyLighting().
4  */
5 
6 #version 150
7 
8 in vec4 vVertex;
9 in vec3 vNormal;
10 in vec4 vTexCoord0;
11 
12 uniform mat4 modelViewMatrix;
13 uniform mat4 projectionMatrix;
14 uniform mat4 mvpMatrix;
15 uniform mat3 normalMatrix;
16 uniform mat4 textureMatrix;
17 
18 smooth out vec4 emissionAmbientDiffuse;
19 smooth out vec4 specular;
20 smooth out vec4 texCoord0;
21 
22 
23 // --- declarations ---
24 
25 
26 void applyLighting(const in vec3 ecVertex, const in vec3 ecNormal,
27  out vec4 emissionAmbientDiffuse, out vec4 specular);
28 
29 
30 // --- implementations ---
31 
32 
33 void main() {
34 
35  // transform vertex position and normal into eye coordinates
36  vec3 ecVertex = (modelViewMatrix * vVertex).xyz;
37  vec3 ecNormal = normalMatrix * vNormal;
38 
39  // apply lighting model (to be defined in separate shader)
40  applyLighting(ecVertex, ecNormal, emissionAmbientDiffuse, specular);
41 
42  // set output values
43  gl_Position = mvpMatrix * vVertex;
44  texCoord0 = textureMatrix * vTexCoord0;
45 }