irrlicht/media/cubeMapReflection.vert
cutealien 2ae2a551a6 Merging r5975 through r6036 from trunk to ogl-es branch.
GLES drivers adapted, but only did make compile-tests.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6038 dfc29bdd-3216-0410-991c-e03cc46cb475
2020-01-03 19:05:16 +00:00

28 lines
837 B
GLSL

uniform int StyleUVW ; // 0 = specular reflection, 1 = diffuse reflection, 2 = use model vertex coordinates for uvw.
uniform vec3 CameraPos;
uniform mat4 World;
void main(void)
{
gl_Position = ftransform(); // same as gl_ModelViewProjectionMatrix * gl_Vertex;
// compute the reflection vector, and assign it to texcoord 0
if ( StyleUVW == 0 )
{
vec4 worldPos = World*gl_Vertex;
vec3 viewNormal = normalize(worldPos.xyz - CameraPos); // view vector
gl_TexCoord[0] = vec4( reflect( viewNormal, normalize(gl_Normal) ), 1.0 );
}
else if ( StyleUVW == 1 )
{
// just use the normal for the reflection vector
gl_TexCoord[0] = vec4(normalize(gl_Normal), 1.0);
}
else if ( StyleUVW == 2 )
{
// use vertex-coordinates for texture coordinates
gl_TexCoord[0] = normalize(gl_Vertex);
}
}