38 lines
979 B
GLSL
38 lines
979 B
GLSL
|
#version 420 core
|
||
|
|
||
|
layout(location = 0) in vec3 pos;
|
||
|
layout(location = 1) in vec2 inTexCoord;
|
||
|
layout(location = 2) in vec3 normals;
|
||
|
|
||
|
layout(std140, binding = 0) uniform Camera
|
||
|
{
|
||
|
mat4 projection;
|
||
|
mat4 view;
|
||
|
vec3 position;
|
||
|
} camera;
|
||
|
|
||
|
layout(std140, binding = 2) uniform Light
|
||
|
{
|
||
|
vec3 position;
|
||
|
vec3 color;
|
||
|
} light_v;
|
||
|
|
||
|
uniform mat4 model;
|
||
|
|
||
|
out vec2 texCoord;
|
||
|
|
||
|
out vec3 Cam_vertex; // Позиция камеры относительно вершины
|
||
|
out vec3 L_vertex; // Позиция источника света относительно вершины
|
||
|
out vec3 N; // Нормаль трансформированноая
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
vec4 P = model * vec4(pos, 1.0); // трансформация вершины
|
||
|
|
||
|
Cam_vertex = normalize(camera.position - P.xyz);
|
||
|
L_vertex = normalize(light_v.position - P.xyz);
|
||
|
N = normalize(mat3(model) * normals);
|
||
|
|
||
|
gl_Position = camera.projection * camera.view * P;
|
||
|
texCoord = inTexCoord;
|
||
|
}
|