double-hit-balls/assets/parallax_vertex.txt

60 lines
1.3 KiB
Plaintext
Raw Normal View History

2017-12-11 09:30:51 +00:00
attribute vec3 vPosition;
attribute vec2 vTexCoord;
uniform vec3 eye;
uniform mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ProjectionMatrix1;
uniform mat3 ModelViewMatrix3x3;
varying vec2 frag_uv;
varying vec3 ts_light_pos; // Tangent space values
varying vec3 ts_view_pos; //
varying vec3 ts_frag_pos; //
mat3 transpose(in mat3 inMatrix)
{
vec3 i0 = inMatrix[0];
vec3 i1 = inMatrix[1];
vec3 i2 = inMatrix[2];
mat3 outMatrix = mat3(
vec3(i0.x, i1.x, i2.x),
vec3(i0.y, i1.y, i2.y),
vec3(i0.z, i1.z, i2.z)
);
return outMatrix;
}
void main()
{
vec3 vert_norm = vec3(0, 1, 0);
vec3 vert_tang = vec3(1, 0, 0);
vec3 vert_bitang = vec3(0, 0, 1);
mat4 mvp = ProjectionMatrix1 * ModelViewMatrix;
gl_Position = mvp * vec4(vPosition.xyz, 1.0);
ts_frag_pos = vec3(ModelViewMatrix * vec4(vPosition.xyz, 1.0));
vec3 t = normalize((NormalMatrix) * vert_tang);
vec3 b = normalize((NormalMatrix) * vert_bitang);
vec3 n = normalize((NormalMatrix) * vert_norm);
mat3 tbn = transpose(mat3(t, b, n));
ts_light_pos = tbn * vec3(1,2,0);
//ts_view_pos = tbn * eye;
ts_view_pos = tbn * vec3(0,0,0);
ts_frag_pos = tbn * ts_frag_pos;
frag_uv = vTexCoord;
}