48 lines
1005 B
Plaintext
48 lines
1005 B
Plaintext
|
attribute vec3 vPosition;
|
||
|
attribute vec2 vTexCoord;
|
||
|
|
||
|
uniform vec3 CamPos;
|
||
|
uniform mat3 ModelRotateMatrix;
|
||
|
uniform vec3 ModelTranslateVector;
|
||
|
|
||
|
uniform mat4 ProjectionMatrix;
|
||
|
uniform mat4 ProjectionMatrix1;
|
||
|
|
||
|
attribute vec3 Tangent;
|
||
|
attribute vec3 Binormal;
|
||
|
|
||
|
varying vec2 texCoord;
|
||
|
varying vec3 camVec;
|
||
|
varying vec3 lightVec;
|
||
|
varying vec3 vertexPos;
|
||
|
|
||
|
//For shadows
|
||
|
varying vec4 vPos;
|
||
|
varying vec4 gPos;
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
|
||
|
gl_Position = ProjectionMatrix * realVertexPos;
|
||
|
|
||
|
texCoord = gl_MultiTexCoord0.st;
|
||
|
|
||
|
vec3 lVec = normalize(gl_LightSource[0].position.xyz);
|
||
|
vec3 cVec = (CamPos - vPosition.xyz);
|
||
|
|
||
|
vertexPos = vPosition.xyz;
|
||
|
|
||
|
mat3 rot;
|
||
|
rot[0] = normalize(Tangent);
|
||
|
rot[1] = normalize(Binormal);
|
||
|
rot[2] = normalize(gl_Normal.xyz);
|
||
|
|
||
|
rot = ModelRotateMatrix * rot;
|
||
|
|
||
|
lightVec = lVec * rot;
|
||
|
camVec = cVec * rot;
|
||
|
|
||
|
//For shadows
|
||
|
vPos = realVertexPos;
|
||
|
gPos = ProjectionMatrix1 * vec4(vPosition.xyz, 1.0);
|
||
|
}
|