forked from enlightenment/efl
117 lines
2.5 KiB
Plaintext
117 lines
2.5 KiB
Plaintext
uniform mat4 uMatrixMvp;
|
|
uniform mat3 uMatrixNormal;
|
|
uniform mat4 uMatrixModelview;
|
|
uniform vec4 uLightPosition;
|
|
varying vec3 vLightVector;
|
|
varying vec3 vLightHalfVector;
|
|
varying vec3 vNormal;
|
|
|
|
#ifdef SHADOWED
|
|
uniform mat4 uMatrixLight;
|
|
varying vec4 vLightPosition;
|
|
#endif //SHADOWED
|
|
|
|
#ifdef VERTEX_POSITION
|
|
attribute vec4 aPosition0;
|
|
#endif //VERTEX_POSITION
|
|
|
|
#ifdef VERTEX_POSITION_BLEND
|
|
attribute vec4 aPosition1;
|
|
uniform float uPositionWeight;
|
|
#endif //VERTEX_POSITION_BLEND
|
|
|
|
#ifdef VERTEX_NORMAL
|
|
attribute vec4 aNormal0;
|
|
#endif //VERTEX_NORMAL
|
|
|
|
#ifdef VERTEX_NORMAL_BLEND
|
|
attribute vec4 aNormal1;
|
|
uniform float uNormalWeight;
|
|
#endif //VERTEX_NORMAL_BLEND
|
|
|
|
#ifdef VERTEX_TEXCOORD
|
|
attribute vec4 aTexCoord0;
|
|
#endif //VERTEX_TEXCOORD
|
|
|
|
#ifdef VERTEX_TEXCOORD_BLEND
|
|
attribute vec4 aTexCoord1;
|
|
uniform float uTexCoordWeight;
|
|
#endif //VERTEX_TEXCOORD_BLEND
|
|
|
|
#ifdef NEED_TEX_COORD
|
|
varying vec2 vTexCoord;
|
|
#endif //NEED_TEX_COORD
|
|
|
|
#ifdef LIGHT_ATTENUATION
|
|
varying float vLightDist;
|
|
#endif //LIGHT_ATTENUATION
|
|
|
|
void vertexPhong(vec4 position, vec3 normal)
|
|
{
|
|
normal = uMatrixNormal * normal;
|
|
position = uMatrixModelview * position;
|
|
|
|
#ifdef NORMALIZE_NORMALS
|
|
normal = normalize(normal);
|
|
#endif //NORMALIZE_NORMALS
|
|
|
|
#ifdef LIGHT_DIRECTIONAL
|
|
vLightVector = uLightPosition.xyz;
|
|
#else
|
|
vLightVector = uLightPosition.xyz - position.xyz;
|
|
|
|
#ifdef LIGHT_ATTENUATION
|
|
vLightDist = length(vLightVector);
|
|
#endif //LIGHT_ATTENUATION
|
|
|
|
vLightVector = normalize(vLightVector);
|
|
#endif //LIGHT_DIRECTIONAL
|
|
|
|
vLightHalfVector = normalize(normalize(-position.xyz) + vLightVector);
|
|
vNormal = normal;
|
|
}
|
|
|
|
void main() {
|
|
|
|
#ifdef VERTEX_POSITION_BLEND
|
|
vec4 position = aPosition0 * uPositionWeight +
|
|
aPosition1 * (1.0 - uPositionWeight);
|
|
position = vec4(position.xyz, 1.0);
|
|
#else
|
|
|
|
#ifdef VERTEX_POSITION
|
|
vec4 position = vec4(aPosition0.xyz, 1.0);
|
|
#endif // VERTEX_POSITION
|
|
|
|
#endif //VERTEX_POSITION_BLEND
|
|
|
|
#ifdef VERTEX_NORMAL_BLEND
|
|
vec3 normal = aNormal0.xyz * uNormalWeight +
|
|
aNormal1.xyz * (1.0 - uNormalWeight);
|
|
#else
|
|
|
|
#ifdef VERTEX_NORMAL
|
|
vec3 normal = aNormal0.xyz;
|
|
#endif //VERTEX_NORMAL
|
|
|
|
#endif //VERTEX_NORMAL_BLEND
|
|
|
|
#ifdef VERTEX_TEXCOORD_BLEND
|
|
vTexCoord = aTexCoord0.st * uTexCoordWeight +
|
|
aTexCoord1.st * (1.0 - uTexCoordWeight);
|
|
#else
|
|
|
|
#ifdef VERTEX_TEXCOORD
|
|
vTexCoord = aTexCoord0.st;
|
|
#endif //VERTEX_TEXCOORD
|
|
|
|
#endif //VERTEX_TEXCOORD_BLEND
|
|
|
|
gl_Position = uMatrixMvp * position;
|
|
vertexPhong(position, normal);
|
|
|
|
#ifdef SHADOWED
|
|
vLightPosition = uMatrixLight * position;
|
|
#endif //SHADOWED
|
|
}
|