diff options
author | HampusM <hampus@hampusmat.com> | 2024-11-23 21:32:03 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-11-23 21:32:03 +0100 |
commit | daf280048d82eed42d44423ce50ae9e809ba91a9 (patch) | |
tree | fdd1580b3c50f2f7cebc5175b38777a7117c904f /engine/src/renderer/opengl/glsl/vertex.glsl | |
parent | 999264a46f9a545771c6710b0893ca32cf6e7ee3 (diff) |
refactor(engine): make shaders a renderer detail
Diffstat (limited to 'engine/src/renderer/opengl/glsl/vertex.glsl')
-rw-r--r-- | engine/src/renderer/opengl/glsl/vertex.glsl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/engine/src/renderer/opengl/glsl/vertex.glsl b/engine/src/renderer/opengl/glsl/vertex.glsl new file mode 100644 index 0000000..b57caa6 --- /dev/null +++ b/engine/src/renderer/opengl/glsl/vertex.glsl @@ -0,0 +1,24 @@ +#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 VertexData vertex_data; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +void main() +{ + gl_Position = projection * view * model * vec4(pos, 1.0); + + 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 + vertex_data.world_space_normal = mat3(transpose(inverse(model))) * normal; +} |