53 lines
1.2 KiB
GLSL
53 lines
1.2 KiB
GLSL
#version 330 core
|
|
layout (location = 0) in vec3 aPos;
|
|
layout (location = 1) in vec3 aColor;
|
|
|
|
out vec3 ourColor;
|
|
|
|
uniform float f;
|
|
uniform float aspect;
|
|
uniform float zFar;
|
|
uniform float zNear;
|
|
uniform float theta;
|
|
uniform vec3 cameraPosition;
|
|
uniform vec3 cameraRotation;
|
|
|
|
void main()
|
|
{
|
|
/* mat4 realprojectionMatrix = mat4(
|
|
f / aspect, 0, 0, 0,
|
|
0, f, 0, 0,
|
|
0, 0, (zFar + zNear) / (zNear - zFar), -1,
|
|
0, 0, (2 * zFar * zNear) / (zNear - zFar), 0
|
|
);
|
|
*/
|
|
mat4 projectionMatrix = mat4(
|
|
3 / (800.0 / 600.0), 0, 0, 0,
|
|
0, 3, 0, 0,
|
|
0, 0, (10 + 1) / (1 - 10), -1,
|
|
0, 0, (2 * 10 * 1) / (1 - 10), 0
|
|
);
|
|
|
|
mat4 cameraRotationMatrix = mat4(
|
|
cos(theta), 0, -sin(theta), 0,
|
|
0, 1, 0, 0,
|
|
sin(theta), 0, cos(theta), 0,
|
|
0, 0, 0, 1
|
|
);
|
|
|
|
mat4 cameraPositionMatrix = mat4(
|
|
1, 0, 0, 0,
|
|
0, 1, 0, 0,
|
|
0, 0, 1, 0,
|
|
10 * sin(theta), 0, -10 * cos(theta), 1
|
|
);
|
|
|
|
mat4 viewMatrix = cameraRotationMatrix * cameraPositionMatrix;
|
|
|
|
|
|
vec4 projectedVertex = projectionMatrix * cameraRotationMatrix * cameraPositionMatrix * vec4(aPos, 1.0);
|
|
gl_Position = projectedVertex / projectedVertex.w;
|
|
ourColor = aColor;
|
|
}
|
|
|