47 lines
964 B
Plaintext
47 lines
964 B
Plaintext
/*
|
|
Bump/parallax mapping shader for single directional light source
|
|
The fastest shader for bump/bump mapping
|
|
|
|
*/
|
|
|
|
uniform vec3 CamPos;
|
|
uniform mat3 ModelRotateMatrix;
|
|
uniform vec3 ModelTranslateVector;
|
|
|
|
attribute vec3 Tangent;
|
|
attribute vec3 Binormal;
|
|
|
|
varying vec2 texCoord;
|
|
varying vec3 camVec;
|
|
varying vec3 lightVec;
|
|
|
|
//for fragment shader
|
|
varying vec4 vPos;
|
|
varying vec4 gPos;
|
|
|
|
void main()
|
|
{
|
|
vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0);
|
|
gl_Position = gl_ModelViewProjectionMatrix * realVertexPos;
|
|
|
|
texCoord = gl_MultiTexCoord0.st;
|
|
|
|
vec3 lVec = normalize(gl_LightSource[0].position.xyz);
|
|
vec3 cVec = (CamPos - gl_Vertex.xyz);
|
|
|
|
mat3 rot;
|
|
rot[0] = Tangent;
|
|
rot[1] = Binormal;
|
|
rot[2] = gl_Normal.xyz;
|
|
|
|
rot = ModelRotateMatrix * rot;
|
|
|
|
lightVec = lVec * rot;
|
|
camVec = cVec * rot;
|
|
|
|
//For shadows
|
|
vPos = realVertexPos;
|
|
gPos = gl_ProjectionMatrix * gl_Position;
|
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
|
}
|