mirror of
https://github.com/minetest/minetest.git
synced 2024-12-25 15:42:24 +01:00
54 lines
1.2 KiB
GLSL
54 lines
1.2 KiB
GLSL
uniform mat4 mWorld;
|
|
|
|
uniform vec3 eyePosition;
|
|
uniform float animationTimer;
|
|
|
|
varying vec3 vNormal;
|
|
varying vec3 vPosition;
|
|
varying vec3 worldPosition;
|
|
varying lowp vec4 varColor;
|
|
#ifdef GL_ES
|
|
varying mediump vec2 varTexCoord;
|
|
#else
|
|
centroid varying vec2 varTexCoord;
|
|
#endif
|
|
|
|
varying vec3 eyeVec;
|
|
varying float vIDiff;
|
|
|
|
const float e = 2.718281828459;
|
|
const float BS = 10.0;
|
|
|
|
float directional_ambient(vec3 normal)
|
|
{
|
|
vec3 v = normal * normal;
|
|
|
|
if (normal.y < 0.0)
|
|
return dot(v, vec3(0.670820, 0.447213, 0.836660));
|
|
|
|
return dot(v, vec3(0.670820, 1.000000, 0.836660));
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
varTexCoord = (mTexture * inTexCoord0).st;
|
|
gl_Position = mWorldViewProj * inVertexPosition;
|
|
|
|
vPosition = gl_Position.xyz;
|
|
vNormal = inVertexNormal;
|
|
worldPosition = (mWorld * inVertexPosition).xyz;
|
|
eyeVec = -(mWorldView * inVertexPosition).xyz;
|
|
|
|
#if (MATERIAL_TYPE == TILE_MATERIAL_PLAIN) || (MATERIAL_TYPE == TILE_MATERIAL_PLAIN_ALPHA)
|
|
vIDiff = 1.0;
|
|
#else
|
|
// This is intentional comparison with zero without any margin.
|
|
// If normal is not equal to zero exactly, then we assume it's a valid, just not normalized vector
|
|
vIDiff = length(inVertexNormal) == 0.0
|
|
? 1.0
|
|
: directional_ambient(normalize(inVertexNormal));
|
|
#endif
|
|
|
|
varColor = inVertexColor;
|
|
}
|