-
Notifications
You must be signed in to change notification settings - Fork 2
/
env.vert
29 lines (24 loc) · 1.09 KB
/
env.vert
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#version 330 core
// NOTE: Do NOT use any version older than 330! Bad things will happen!
// This is an example vertex shader. GLSL is very similar to C.
// You can define extra functions if needed, and the main() function is
// called when the vertex shader gets run.
// The vertex shader gets called once per vertex.
layout (location = 0) in vec3 position;
layout (location = 2) in vec3 normal;
// Uniform variables can be updated by fetching their location and passing values to that location
uniform mat4 projection;
uniform mat4 model;
uniform mat4 view;
// Outputs of the vertex shader are the inputs of the same name of the fragment shader.
// The default output, gl_Position, should be assigned something. You can define as many
// extra outputs as you need.
out vec3 Normal;
out vec3 Position;
void main()
{
// OpenGL maintains the D matrix so you only need to multiply by P, V (aka C inverse), and M
gl_Position = projection * view * model * vec4(position.x, position.y, position.z, 1.0);
Normal = mat3(transpose(inverse(model))) * normal;
Position = -vec3(model * vec4(position, 1.0f));
}