scg3  0.6
cube_map_vert.glsl
Go to the documentation of this file.
1 /**
2  * \file cube_map_vert.glsl
3  * \brief Cube map vertex shader without shading.
4  */
5 
6 #version 150
7 
8 in vec4 vVertex;
9 in vec3 vNormal;
10 
11 uniform mat4 modelViewMatrix;
12 uniform mat4 mvpMatrix;
13 uniform mat3 normalMatrix;
14 uniform mat4 invViewMatrix;
15 
16 smooth out vec3 texCoord0;
17 
18 
19 void main() {
20 
21  // transform vertex position and normal into eye coordinates
22  vec3 ecVertex = (modelViewMatrix * vVertex).xyz;
23  vec3 ecNormal = normalMatrix * vNormal;
24 
25  // compute reflection for cube mapping
26  vec4 ecReflection = vec4(reflect(normalize(ecVertex), normalize(ecNormal)), 0.);
27 
28  // set output values
29  gl_Position = mvpMatrix * vVertex;
30  texCoord0 = (invViewMatrix * ecReflection).stp;
31 }