38 lines
870 B
Plaintext
38 lines
870 B
Plaintext
|
// Bump mapping shader without parallax mapping for single light source
|
||
|
// Slower than directlight_bump but faster than multilight_bump
|
||
|
|
||
|
uniform vec3 CamPos;
|
||
|
uniform mat3 ModelRotateMatrix;
|
||
|
uniform vec3 ModelTranslateVector;
|
||
|
|
||
|
attribute vec3 Tangent;
|
||
|
attribute vec3 Binormal;
|
||
|
|
||
|
varying vec2 texCoord;
|
||
|
varying vec3 camVec;
|
||
|
varying vec3 lightVec;
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
gl_Position = gl_ModelViewProjectionMatrix * vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0);
|
||
|
texCoord = gl_MultiTexCoord0.st;
|
||
|
|
||
|
vec3 lVec;
|
||
|
|
||
|
if (gl_LightSource[0].position.w == 0.0)
|
||
|
lVec = gl_LightSource[0].position.xyz;
|
||
|
else
|
||
|
lVec = gl_LightSource[0].position.xyz - gl_Vertex.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;
|
||
|
}
|