]> git.lizzy.rs Git - irrlicht.git/blob - media/cubeMapReflection.vert
Enable ogles2 on mobile platforms by default
[irrlicht.git] / media / cubeMapReflection.vert
1 uniform int StyleUVW ; // 0 = specular reflection, 1 = diffuse reflection, 2 = use model vertex coordinates for uvw.\r
2 uniform vec3  CameraPos;\r
3 uniform mat4 World;\r
4 \r
5 void main(void)\r
6 {\r
7         gl_Position = ftransform();     // same as gl_ModelViewProjectionMatrix * gl_Vertex;\r
8         \r
9     // compute the reflection vector, and assign it to texcoord 0\r
10         if ( StyleUVW == 0 )\r
11         {\r
12                 vec4 worldPos = World*gl_Vertex;\r
13                 vec3 viewNormal = normalize(worldPos.xyz - CameraPos);  // view vector\r
14         \r
15                 gl_TexCoord[0] = vec4( reflect( viewNormal, normalize(gl_Normal) ), 1.0 );\r
16         }\r
17         else if ( StyleUVW == 1 )\r
18         {\r
19                 // just use the normal for the reflection vector\r
20                 gl_TexCoord[0] = vec4(normalize(gl_Normal), 1.0);\r
21         }\r
22         else if ( StyleUVW == 2 )\r
23         {\r
24                 // use vertex-coordinates for texture coordinates\r
25                 gl_TexCoord[0] = normalize(gl_Vertex);\r
26         }       \r
27 }\r