ho3/resources/shaders/NIU/multilight_parallax.vertex

49 lines
1004 B
Plaintext
Raw Permalink Normal View History

2024-06-06 13:25:38 +00:00
/*
Bump/parallax mapping shader for not more than 8 light sources
The slowest bump/parallax mapping shader
*/
uniform vec3 CamPos;
uniform mat3 ModelRotateMatrix;
uniform vec3 ModelTranslateVector;
uniform int ActiveLightCount;
attribute vec3 Tangent;
attribute vec3 Binormal;
varying vec2 texCoord;
varying int activeLightCount;
varying vec3 camVec;
varying vec3 lightVec[8];
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0);
texCoord = gl_MultiTexCoord0.st;
activeLightCount = ActiveLightCount;
mat3 rot;
rot[0] = Tangent;
rot[1] = Binormal;
rot[2] = gl_Normal.xyz;
rot = ModelRotateMatrix * rot;
vec3 lVec;
vec3 cVec = (CamPos - gl_Vertex.xyz);
camVec = cVec * rot;
for (int i=0;i<ActiveLightCount;i++)
{
if (gl_LightSource[i].position.w == 0.0)
lVec = gl_LightSource[i].position.xyz;
else
lVec = gl_LightSource[i].position.xyz - gl_Vertex.xyz;
lightVec[i] = lVec * rot;
}
}