SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::VertexLayoutDesc Struct Reference

#include <VertexLayout.hpp>

Public Attributes

std::vector< VertexAttributeattributes
std::string gbufferShaderStem
std::string shaderStem
std::string shadowShaderStem
uint32_t stride = 0
std::string transparentShaderStem

Detailed Description

A complete custom vertex layout plus the shader stems that consume it. Register once at startup; the handle keys pipelines and mesh creation. Shader stems are consumed by the Vulkan backend; OpenGL instead binds the layout's attributes to its own fixed shader programs.

Fill one of these when your geometry does not fit the engine's built-in vertex type: packed voxel vertices, extra UV sets, per-vertex instance data, anything you want to define yourself. stride is the size of one vertex in bytes and each VertexAttribute gives a shader location, a component format, and a byte offset inside that vertex.

The four shader stems name the pipeline variants the format participates in. An empty stem skips that pass entirely, so a format with no shadowShaderStem casts no shadows and a format with no gbufferShaderStem is forward only. There is no fallback shader: if a named stem fails to load, the backend logs an error and skips that pass for this format.

struct VoxelVertex {
float position[3];
float normal[3];
float uv[2];
uint32_t packedLight;
};
desc.stride = sizeof(VoxelVertex);
desc.attributes = {
offsetof(VoxelVertex, position)},
offsetof(VoxelVertex, normal)},
{2, Sleak::VertexAttribFormat::Float2, offsetof(VoxelVertex, uv)},
offsetof(VoxelVertex, packedLight)},
};
desc.shaderStem = "flat_shader";
desc.shadowShaderStem = "shadow_depth_voxel";
desc.gbufferShaderStem = "gbuffer_voxel";
desc.transparentShaderStem = "water_shader";
static VertexFormatHandle Register(const VertexLayoutDesc &desc)
uint32_t VertexFormatHandle
std::string transparentShaderStem
std::vector< VertexAttribute > attributes
See also
VertexFormatRegistry, VertexAttribute, VertexAttribFormat, MeshBatch

Definition at line 74 of file VertexLayout.hpp.

Member Data Documentation

◆ attributes

std::vector<VertexAttribute> Sleak::VertexLayoutDesc::attributes

Definition at line 76 of file VertexLayout.hpp.

◆ gbufferShaderStem

std::string Sleak::VertexLayoutDesc::gbufferShaderStem

Definition at line 81 of file VertexLayout.hpp.

◆ shaderStem

std::string Sleak::VertexLayoutDesc::shaderStem

Definition at line 77 of file VertexLayout.hpp.

◆ shadowShaderStem

std::string Sleak::VertexLayoutDesc::shadowShaderStem

Definition at line 79 of file VertexLayout.hpp.

◆ stride

uint32_t Sleak::VertexLayoutDesc::stride = 0

Definition at line 75 of file VertexLayout.hpp.

◆ transparentShaderStem

std::string Sleak::VertexLayoutDesc::transparentShaderStem

Definition at line 83 of file VertexLayout.hpp.