summary refs log tree commit diff
path: root/assets/shaders/vertex.glsl
blob: 3ca10551cb2fb2cf80b8abea2442cb31720ff290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#version 330 core

uniform mat4 model_matrix;
uniform mat4 view_matrix;
uniform mat4 projection_matrix;

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 tex_coord;

out vec2 frag_tex_coord;
out vec3 surface_normal;
out float depth;

void main() {
    vec4 world_position = model_matrix * vec4(position, 1.0);
    vec4 view_position = view_matrix * world_position;
    vec4 clip_position = projection_matrix * view_position;

    gl_Position = clip_position;
    frag_tex_coord = tex_coord;
    surface_normal = (model_matrix * vec4(normal, 0.0)).xyz;
    depth = clamp((length(view_position) - 75) / 125, 0.0, 1.0);
}