2020-02-16 20:37:28 +01:00
|
|
|
uniform mat4 mWorld;
|
|
|
|
|
|
|
|
uniform vec3 eyePosition;
|
|
|
|
uniform float animationTimer;
|
|
|
|
|
|
|
|
varying vec3 vNormal;
|
|
|
|
varying vec3 vPosition;
|
|
|
|
varying vec3 worldPosition;
|
2020-10-25 18:01:03 +01:00
|
|
|
varying lowp vec4 varColor;
|
2020-12-22 14:53:52 +01:00
|
|
|
#ifdef GL_ES
|
|
|
|
varying mediump vec2 varTexCoord;
|
|
|
|
#else
|
|
|
|
centroid varying vec2 varTexCoord;
|
|
|
|
#endif
|
2020-02-16 20:37:28 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-10-25 18:01:03 +01:00
|
|
|
if (normal.y < 0.0)
|
|
|
|
return dot(v, vec3(0.670820, 0.447213, 0.836660));
|
2020-02-16 20:37:28 +01:00
|
|
|
|
2020-10-25 18:01:03 +01:00
|
|
|
return dot(v, vec3(0.670820, 1.000000, 0.836660));
|
2020-02-16 20:37:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2020-10-25 18:01:03 +01:00
|
|
|
varTexCoord = (mTexture * inTexCoord0).st;
|
|
|
|
gl_Position = mWorldViewProj * inVertexPosition;
|
2020-02-16 20:37:28 +01:00
|
|
|
|
|
|
|
vPosition = gl_Position.xyz;
|
2020-10-25 18:01:03 +01:00
|
|
|
vNormal = inVertexNormal;
|
|
|
|
worldPosition = (mWorld * inVertexPosition).xyz;
|
|
|
|
eyeVec = -(mWorldView * inVertexPosition).xyz;
|
2020-06-09 21:38:09 +02:00
|
|
|
|
2020-06-16 21:48:31 +02:00
|
|
|
#if (MATERIAL_TYPE == TILE_MATERIAL_PLAIN) || (MATERIAL_TYPE == TILE_MATERIAL_PLAIN_ALPHA)
|
|
|
|
vIDiff = 1.0;
|
|
|
|
#else
|
2020-06-09 21:38:09 +02:00
|
|
|
// 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
|
2020-10-25 18:01:03 +01:00
|
|
|
vIDiff = length(inVertexNormal) == 0.0
|
2020-06-09 21:38:09 +02:00
|
|
|
? 1.0
|
2020-10-25 18:01:03 +01:00
|
|
|
: directional_ambient(normalize(inVertexNormal));
|
2020-06-16 21:48:31 +02:00
|
|
|
#endif
|
2020-02-16 20:37:28 +01:00
|
|
|
|
2020-10-25 18:01:03 +01:00
|
|
|
varColor = inVertexColor;
|
2020-02-16 20:37:28 +01:00
|
|
|
}
|