MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VertexSpec.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Nodes {
6
7/**
8 * @struct PointVertex
9 * @brief Vertex type for point primitives (POINT_LIST topology)
10 *
11 * Layout (60 bytes):
12 * offset 0 — position vec3 (12)
13 * offset 12 — color vec3 (12)
14 * offset 24 — size float (4)
15 * offset 28 — uv vec2 (8)
16 * offset 36 — normal vec3 (12)
17 * offset 48 — tangent vec3 (12)
18 */
20 glm::vec3 position;
21 glm::vec3 color = glm::vec3(1.0F);
22 float size = 10.0F;
23 glm::vec2 uv = glm::vec2(0.0F);
24 glm::vec3 normal = glm::vec3(0.0F, 0.0F, 1.0F);
25 glm::vec3 tangent = glm::vec3(1.0F, 0.0F, 0.0F);
26};
27
28/**
29 * @struct LineVertex
30 * @brief Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
31 *
32 * Layout (60 bytes):
33 * offset 0 — position vec3 (12)
34 * offset 12 — color vec3 (12)
35 * offset 24 — thickness float (4)
36 * offset 28 — uv vec2 (8)
37 * offset 36 — normal vec3 (12)
38 * offset 48 — tangent vec3 (12)
39 */
40struct LineVertex {
41 glm::vec3 position;
42 glm::vec3 color = glm::vec3(1.0F);
43 float thickness = 2.0F;
44 glm::vec2 uv = glm::vec2(0.0F);
45 glm::vec3 normal = glm::vec3(0.0F, 0.0F, 1.0F);
46 glm::vec3 tangent = glm::vec3(1.0F, 0.0F, 0.0F);
47};
48
49/**
50 * @struct MeshVertex
51 * @brief Vertex type for indexed triangle mesh primitives (TRIANGLE_LIST topology)
52 *
53 * Shares the universal 60-byte layout with PointVertex and LineVertex.
54 * The scalar field at offset 24 is interpreted as a per-vertex weight
55 * (displacement magnitude, blend factor, or any user-defined scalar).
56 * FieldOperator works identically on MeshVertex data: same stride,
57 * same offsets, same raw byte buffer approach.
58 *
59 * Layout (60 bytes):
60 * offset 0 position vec3 (12)
61 * offset 12 color vec3 (12)
62 * offset 24 weight float (4)
63 * offset 28 uv vec2 (8)
64 * offset 36 normal vec3 (12)
65 * offset 48 tangent vec3 (12)
66 *
67 * Intended for use with an external index buffer (uint32_t).
68 * GeometryWriterNode::set_vertices<MeshVertex>() populates vertex data.
69 * Index data is stored separately (see GeometryBuffer index support).
70 */
71struct MeshVertex {
72 glm::vec3 position;
73 glm::vec3 color = glm::vec3(1.0F);
74 float weight = 0.0F;
75 glm::vec2 uv = glm::vec2(0.0F);
76 glm::vec3 normal = glm::vec3(0.0F, 0.0F, 1.0F);
77 glm::vec3 tangent = glm::vec3(1.0F, 0.0F, 0.0F);
78};
79
80static_assert(sizeof(PointVertex) == 60,
81 "PointVertex layout changed — update VertexLayout::for_points(), VertexAccess write helpers, and shaders");
82static_assert(sizeof(LineVertex) == 60,
83 "LineVertex layout changed — update VertexLayout::for_lines(), VertexAccess write helpers, and shaders");
84static_assert(sizeof(MeshVertex) == 60,
85 "MeshVertex layout changed — must match PointVertex/LineVertex stride for FieldOperator compatibility");
86
87static_assert(offsetof(MeshVertex, position) == 0, "position must be at offset 0");
88static_assert(offsetof(MeshVertex, color) == 12, "color must be at offset 12");
89static_assert(offsetof(MeshVertex, weight) == 24, "weight must be at offset 24");
90static_assert(offsetof(MeshVertex, uv) == 28, "uv must be at offset 28");
91static_assert(offsetof(MeshVertex, normal) == 36, "normal must be at offset 36");
92static_assert(offsetof(MeshVertex, tangent) == 48, "tangent must be at offset 48");
93
94/**
95 * @struct TextureQuadVertex
96 * @brief Vertex layout for textured quad geometry (position + UV).
97 *
98 * Matches the vertex input expected by texture.vert.spv:
99 * location 0 → vec3 position, location 1 → vec2 texcoord.
100 */
102 glm::vec3 position;
103 glm::vec2 texcoord;
104};
105
106/**
107 * @brief Deduce a VertexLayout from a vertex struct type.
108 */
109template <typename T>
111{
112 if constexpr (std::is_same_v<T, PointVertex>) {
114 } else if constexpr (std::is_same_v<T, LineVertex>) {
116 } else if constexpr (std::is_same_v<T, MeshVertex>) {
118 } else {
119 static_assert(!std::is_same_v<T, T>,
120 "vertex_layout_for: unrecognised vertex type");
121 }
122}
123
124} // namespace MayaFlux::Nodes
double weight
glm::vec3 position
std::optional< glm::vec3 > color
Kakshya::VertexLayout vertex_layout_for()
Deduce a VertexLayout from a vertex struct type.
Contains the node-based computational processing system components.
Definition Chronie.hpp:13
static VertexLayout for_lines(uint32_t stride=60)
Factory: layout for LineVertex (position, color, thickness, uv, normal, tangent)
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)
static VertexLayout for_points(uint32_t stride=60)
Factory: layout for PointVertex (position, color, size, uv, normal, tangent)
Complete description of vertex data layout in a buffer.
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
Vertex type for indexed triangle mesh primitives (TRIANGLE_LIST topology)
Vertex type for point primitives (POINT_LIST topology)
Vertex layout for textured quad geometry (position + UV).