Modify vertex shaders to use new uniforms

This commit is contained in:
Kevin Anthoney 2014-07-09 09:40:26 +01:00
parent 59d29c6431
commit 2dd2996737
3 changed files with 16 additions and 8 deletions

View File

@ -42,6 +42,8 @@ uniform vec4 uOffsetPlayerPosition;
varying vec4 vColor;
uniform mat4 ooliteModelViewProjection;
void main(void)
{
@ -55,7 +57,7 @@ void main(void)
// Project the dust, and find its distance from the camera.
position.w = 1.0;
position = gl_ModelViewProjectionMatrix * position;
position = ooliteModelViewProjection * position;
gl_Position = position;
float distance = length(position);

View File

@ -21,15 +21,18 @@
MA 02110-1301, USA.
S*/
uniform mat3 ooliteNormalMatrix;
uniform mat4 ooliteModelView;
uniform mat4 ooliteModelViewProjection;
varying vec3 vNormal;
varying vec3 vEyeVector;
void main(void)
{
vNormal = normalize(gl_NormalMatrix * gl_Normal);
vEyeVector = -vec3(gl_ModelViewMatrix * gl_Vertex);
vNormal = normalize(ooliteNormalMatrix * gl_Normal);
vEyeVector = -vec3(ooliteModelView * gl_Vertex);
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = ooliteModelViewProjection * gl_Vertex;
}

View File

@ -26,6 +26,9 @@
attribute vec3 tangent;
uniform mat3 ooliteNormalMatrix;
uniform mat4 ooliteModelView;
uniform mat4 ooliteModelViewProjection;
// No vNormal, because normal is always 0,0,1 in tangent space.
varying vec3 vEyeVector;
@ -44,13 +47,13 @@ varying vec3 vCubeTexCoords;
void main(void)
{
// Build tangent basis
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
vec3 t = normalize(gl_NormalMatrix * tangent);
vec3 n = normalize(ooliteNormalMatrix * gl_Normal);
vec3 t = normalize(ooliteNormalMatrix * tangent);
vec3 b = cross(n, t);
mat3 TBN = mat3(t, b, n);
vec3 eyeVector = -vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 eyeVector = -vec3(ooliteModelView * gl_Vertex);
vEyeVector = eyeVector * TBN;
vec3 lightVector = gl_LightSource[1].position.xyz;
@ -62,5 +65,5 @@ void main(void)
vCubeTexCoords = gl_Vertex.xyz;
#endif
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = ooliteModelViewProjection * gl_Vertex;
}