diff options
| author | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
| commit | db41d43345ea73cf7c1bbb29448e52ffb822e3e0 (patch) | |
| tree | 4635d654e301b3f31f8d2626f3bc2c6f2a6e50a8 /src/vulkan_utils.hpp | |
| parent | 7f08187a46e30925e4563585fab2c6f92400330a (diff) | |
| download | engine-db41d43345ea73cf7c1bbb29448e52ffb822e3e0.tar.gz | |
added textures for the hardware renderer
- removed "using" directive in .hpp
- reverse order of arguments for quaternion rotation, i.e. q.rot(v)
instead of v.rot(q), where q is a quaterinon and v a vector
- pass the inverse of the view matrix to render_and_present_frame, to
allow light calculation in shaders (we used to just pass the matrix of
the quaternion of the transformation, i.e. discard scaling and
translations)
- added another mesh and texture (viking_room) for testing purposes
- added transparent background option
- added Quaternion::look_towards(), which is the equivalent of
Matrix4::look_at() but only for rotations
- various improvement to .obj parsing
- load texture coordinates from .obj file
- merged duplicate vertices in Mesh::linearize_indices()
Diffstat (limited to 'src/vulkan_utils.hpp')
| -rw-r--r-- | src/vulkan_utils.hpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/vulkan_utils.hpp b/src/vulkan_utils.hpp index c822caa..54c82c5 100644 --- a/src/vulkan_utils.hpp +++ b/src/vulkan_utils.hpp @@ -39,7 +39,7 @@ struct Vertex { }; } - static constexpr std::array<VkVertexInputAttributeDescription, 2> get_attr_descs() { + static constexpr std::array<VkVertexInputAttributeDescription, 3> get_attr_descs() { return { VkVertexInputAttributeDescription { .location = 0, @@ -53,19 +53,23 @@ struct Vertex { .format = VK_FORMAT_R32G32B32_SFLOAT, .offset = offsetof(Vertex, normal), }, + VkVertexInputAttributeDescription { + .location = 2, + .binding = 0, + .format = VK_FORMAT_R32G32_SFLOAT, + .offset = offsetof(Vertex, uv), + }, }; } engine::math::Vector3 pos; engine::math::Vector3 normal; + engine::math::Vector2 uv; }; // TODO: move to a better place. Also, see TODOs for struct Vertex struct UniformBufferObject { - alignas(16) engine::math::Matrix4 model, view, proj; - // TODO: should me Matrix3, but it isn't implemented yet - alignas(16) engine::math::Matrix4 camera_rot; - alignas(16) engine::math::Vector3 camera_loc; + alignas(16) engine::math::Matrix4 model, view, proj, inv_view; }; } |
