diff options
author | HampusM <hampus@hampusmat.com> | 2024-05-23 20:57:35 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-05-23 20:57:35 +0200 |
commit | f47ce90430f36e74d713e22781a34f89149f7ea5 (patch) | |
tree | 01c2439097a3f51517b02cb4cf3cbbd5c773f478 /engine/vertex.glsl | |
parent | 638c775707240d365432ed910a88a3cbf545a130 (diff) |
refactor(engine): pass vertex data to fragment shader with struct
Diffstat (limited to 'engine/vertex.glsl')
-rw-r--r-- | engine/vertex.glsl | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/engine/vertex.glsl b/engine/vertex.glsl index f282864..b57caa6 100644 --- a/engine/vertex.glsl +++ b/engine/vertex.glsl @@ -1,11 +1,12 @@ #version 330 core + +#preinclude "vertex_data.glsl" + layout (location = 0) in vec3 pos; layout (location = 1) in vec2 texture_coords; layout (location = 2) in vec3 normal; -out vec3 in_frag_pos; -out vec2 in_texture_coords; -out vec3 in_normal; +out VertexData vertex_data; uniform mat4 model; uniform mat4 view; @@ -15,9 +16,9 @@ void main() { gl_Position = projection * view * model * vec4(pos, 1.0); - in_frag_pos = vec3(model * vec4(pos, 1.0)); - in_texture_coords = texture_coords; + vertex_data.world_space_pos = vec3(model * vec4(pos, 1.0)); + vertex_data.texture_coords = texture_coords; // TODO: Do this using CPU for performance increase - in_normal = mat3(transpose(inverse(model))) * normal; + vertex_data.world_space_normal = mat3(transpose(inverse(model))) * normal; } |