mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 15:42:25 +01:00
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);
|
||
|
}
|
||
|
}
|