Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
ClusterLodGenerator.h
Go to the documentation of this file.
1#pragma once
2
13
14#include "Engine/Ecs/EcsData.h"
15#include "Engine/Mesh/Vertex.h"
17#include <vector>
18
19namespace EngineCore
20{
21
26{
28 float simplificationRatio = 0.5f;
29 float targetError = 0.01f;
30 size_t maxLodLevels = 6;
31 size_t minTrianglesForLod = 256;
32};
33
46{
47public:
60 const std::vector<Vertex>& vertices,
61 const std::vector<uint32_t>& indices,
62 const std::vector<meshopt_Meshlet>& baseMeshlets,
63 const std::vector<uint32_t>& baseMeshletVertices,
64 const std::vector<uint8_t>& baseMeshletTriangles,
65 const LodGenerationConfig& config = {}
66 );
67
68private:
73 {
74 std::vector<Vertex> vertices;
75 std::vector<uint32_t> indices;
76 std::vector<meshopt_Meshlet> meshlets;
77 std::vector<uint32_t> meshletVertices;
78 std::vector<uint8_t> meshletTriangles;
79 float error;
80 };
81
83 const std::vector<Vertex>& srcVertices,
84 const std::vector<uint32_t>& srcIndices,
85 size_t targetIndexCount,
86 float targetError,
87 size_t maxVerticesPerMeshlet,
88 size_t maxTrianglesPerMeshlet
89 );
90
94 static glm::vec4 computeBoundingSphere(
95 const std::vector<Vertex>& vertices,
96 const std::vector<uint32_t>& indices
97 );
98
102 static glm::vec4 computeMeshletBoundingSphere(
103 const std::vector<Vertex>& vertices,
104 const meshopt_Meshlet& meshlet,
105 const std::vector<uint32_t>& meshletVertices
106 );
107};
108
109} // namespace EngineCore
Generates LOD hierarchy for meshes using meshoptimizer.
static glm::vec4 computeMeshletBoundingSphere(const std::vector< Vertex > &vertices, const meshopt_Meshlet &meshlet, const std::vector< uint32_t > &meshletVertices)
Compute bounding sphere for a meshlet.
static LodLevelData generateLodLevel(const std::vector< Vertex > &srcVertices, const std::vector< uint32_t > &srcIndices, size_t targetIndexCount, float targetError, size_t maxVerticesPerMeshlet, size_t maxTrianglesPerMeshlet)
static Ecs::LodHierarchyResult generate(const std::vector< Vertex > &vertices, const std::vector< uint32_t > &indices, const std::vector< meshopt_Meshlet > &baseMeshlets, const std::vector< uint32_t > &baseMeshletVertices, const std::vector< uint8_t > &baseMeshletTriangles, const LodGenerationConfig &config={})
Generate LOD hierarchy from mesh geometry.
static glm::vec4 computeBoundingSphere(const std::vector< Vertex > &vertices, const std::vector< uint32_t > &indices)
Compute bounding sphere for a set of vertices.
Log category system implementation.
Result of LOD hierarchy generation for a mesh primitive. Contains per-cluster and per-group data for ...
Definition EcsData.h:234
Generate a single LOD level by simplifying geometry.
float error
Simplification error for this level.
Configuration for LOD hierarchy generation.
size_t maxTrianglesPerCluster
Max triangles per cluster/meshlet.
float simplificationRatio
Reduction ratio per LOD level (0.5 = halve each level)
size_t minTrianglesForLod
Minimum triangles to consider LOD generation.
size_t maxLodLevels
Maximum LOD levels to generate.
float targetError
Target simplification error.