|
|
|
|
@ -2,7 +2,7 @@ uniform mat4 transformationMatrix;
|
|
|
|
|
uniform mat4 projectionMatrix; |
|
|
|
|
uniform vec3 light; |
|
|
|
|
|
|
|
|
|
layout(location = 0) in vec4 vertex; |
|
|
|
|
layout(location = 0) in vec4 position; |
|
|
|
|
layout(location = 1) in vec3 normal; |
|
|
|
|
|
|
|
|
|
out vec3 transformedNormal; |
|
|
|
|
@ -11,18 +11,18 @@ out vec3 cameraDirection;
|
|
|
|
|
|
|
|
|
|
void main() { |
|
|
|
|
/* Transformed vertex position */ |
|
|
|
|
vec4 transformedVertex4 = transformationMatrix*vertex; |
|
|
|
|
vec3 transformedVertex = transformedVertex4.xyz/transformedVertex4.w; |
|
|
|
|
vec4 transformedPosition4 = transformationMatrix*position; |
|
|
|
|
vec3 transformedPosition = transformedPosition4.xyz/transformedPosition4.w; |
|
|
|
|
|
|
|
|
|
/* Transformed normal vector */ |
|
|
|
|
transformedNormal = normalize(mat3x3(transformationMatrix)*normal); |
|
|
|
|
|
|
|
|
|
/* Direction to the light */ |
|
|
|
|
lightDirection = normalize(light - transformedVertex); |
|
|
|
|
lightDirection = normalize(light - transformedPosition); |
|
|
|
|
|
|
|
|
|
/* Direction to the camera */ |
|
|
|
|
cameraDirection = -transformedVertex; |
|
|
|
|
cameraDirection = -transformedPosition; |
|
|
|
|
|
|
|
|
|
/* Transform the vertex */ |
|
|
|
|
gl_Position = projectionMatrix*transformedVertex4; |
|
|
|
|
/* Transform the position */ |
|
|
|
|
gl_Position = projectionMatrix*transformedPosition4; |
|
|
|
|
} |
|
|
|
|
|