46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
attribute vec3 vPosition;
|
|
attribute vec2 vTexCoord;
|
|
|
|
uniform mat4 ProjectionMatrix;
|
|
uniform mat3 ModelRotateMatrix;
|
|
uniform vec3 ModelTranslateVector;
|
|
|
|
varying vec2 texCoord;
|
|
varying vec3 vertexPos;
|
|
|
|
void main()
|
|
{
|
|
vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
|
|
gl_Position = ProjectionMatrix * realVertexPos;
|
|
vertexPos = gl_Position.xyz;
|
|
|
|
texCoord = vTexCoord.st;
|
|
|
|
//vertexPos = vPosition.xyz;
|
|
|
|
//vec3 cVec = (CamPos - vPosition.xyz);
|
|
|
|
/*
|
|
vec3 lVec = normalize(gl_LightSource[0].position.xyz);
|
|
vec3 cVec = (CamPos - vPosition.xyz);
|
|
|
|
vertexPos = vPosition.xyz;
|
|
|
|
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
|
|
|
|
// Используем производные для вычисления тангентного и бинормального вектора
|
|
vec3 dp1 = dFdx(vPosition.xyz);
|
|
vec3 dp2 = dFdy(vPosition.xyz);
|
|
vec2 duv1 = dFdx(vTexCoord.st);
|
|
vec2 duv2 = dFdy(vTexCoord.st);
|
|
|
|
vec3 tangent = normalize(dp1 * duv2.y - dp2 * duv1.y);
|
|
vec3 binormal = normalize(dp2 * duv1.x - dp1 * duv2.x);
|
|
|
|
// Создаем матрицу тангенциального пространства
|
|
mat3 tbnMatrix = mat3(tangent, binormal, normal);
|
|
tbnMatrix = ModelRotateMatrix * tbnMatrix;
|
|
|
|
lightVec = lVec * tbnMatrix;
|
|
camVec = cVec * tbnMatrix;*/
|
|
} |