mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-05 09:50:41 +01:00
8310a3fbad
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6000 dfc29bdd-3216-0410-991c-e03cc46cb475
28 lines
837 B
GLSL
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);
|
|
}
|
|
}
|