vertex +normals

This commit is contained in:
Jérôme Bousquié
2026-07-06 12:31:35 +02:00
parent 6c94fc96d6
commit 47851b8f61
3 changed files with 108 additions and 12 deletions
+7 -3
View File
@@ -8,15 +8,19 @@
//! - `#[repr(C)]` ensures fields are laid out contiguously without Rust padding reordering, matching C ABI.
//! - `bytemuck::Pod + bytemuck::Zeroable` enables safe `cast_slice()` conversion for GPU buffer uploads.
/// Per-vertex attribute tuple: position (3D), texture coordinate (2D), color (RGBA).
/// Per-vertex attribute tuple: position (3D), normal (3D), texture coordinate (2D), color (RGBA).
/// Must match the vertex buffer layout in PipelineCache::build_pipeline() byte-for-byte.
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Vertex {
/// XYZ coordinates of this vertex in world space. Offset: 0 bytes.
pub position: [f32; 3],
/// UV texture coordinates. Offset: 12 bytes (after 3 × f32 = 12 bytes).
/// XYZ coordinates of the vertex normal. Offset: 12 bytes.
pub normal: [f32; 3],
/// UV texture coordinates. Offset: 24 bytes
pub uv: [f32; 2],
/// RGBA color values. Offset: 20 bytes (after 5 × f32 = 20 bytes).
/// RGBA color values. Offset: 32 bytes.
pub color: [f32; 4],
}
// Default values for stability