mirror of https://github.com/axmolengine/axmol.git
52 lines
1.4 KiB
GLSL
52 lines
1.4 KiB
GLSL
#if (MAX_POINT_LIGHT_NUM > 0)
|
|
uniform vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM];
|
|
#endif
|
|
#if (MAX_SPOT_LIGHT_NUM > 0)
|
|
uniform vec3 u_SpotLightSourcePosition[MAX_SPOT_LIGHT_NUM];
|
|
#endif
|
|
|
|
attribute vec4 a_position;
|
|
attribute vec2 a_texCoord;
|
|
attribute vec3 a_normal;
|
|
varying vec2 TextureCoordOut;
|
|
|
|
#if MAX_POINT_LIGHT_NUM
|
|
varying vec3 v_vertexToPointLightDirection[MAX_POINT_LIGHT_NUM];
|
|
#endif
|
|
#if MAX_SPOT_LIGHT_NUM
|
|
varying vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM];
|
|
#endif
|
|
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
|
varying vec3 v_normal;
|
|
#endif
|
|
|
|
uniform mat4 u_MVMatrix;
|
|
uniform mat4 u_PMatrix;
|
|
uniform mat3 u_NormalMatrix;
|
|
void main(void)
|
|
{
|
|
vec4 ePosition = u_MVMatrix * a_position;
|
|
#if (MAX_POINT_LIGHT_NUM > 0)
|
|
for (int i = 0; i < MAX_POINT_LIGHT_NUM; ++i)
|
|
{
|
|
v_vertexToPointLightDirection[i] = u_PointLightSourcePosition[i].xyz - ePosition.xyz;
|
|
}
|
|
#endif
|
|
|
|
#if (MAX_SPOT_LIGHT_NUM > 0)
|
|
for (int i = 0; i < MAX_SPOT_LIGHT_NUM; ++i)
|
|
{
|
|
v_vertexToSpotLightDirection[i] = u_SpotLightSourcePosition[i] - ePosition.xyz;
|
|
}
|
|
#endif
|
|
|
|
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
|
v_normal = u_NormalMatrix * a_normal;
|
|
#endif
|
|
|
|
TextureCoordOut = a_texCoord;
|
|
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
|
gl_Position = u_PMatrix * ePosition;
|
|
}
|
|
|