Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::ClusterLodGenerator Class Reference

Generates LOD hierarchy for meshes using meshoptimizer. More...

#include <ClusterLodGenerator.h>

Classes

struct  LodLevelData
 Generate a single LOD level by simplifying geometry. More...

Static Public Member Functions

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 Private Member Functions

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 glm::vec4 computeBoundingSphere (const std::vector< Vertex > &vertices, const std::vector< uint32_t > &indices)
 Compute bounding sphere for a set of vertices.
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.

Detailed Description

Generates LOD hierarchy for meshes using meshoptimizer.

This generator creates a DAG (Directed Acyclic Graph) of clusters where:

  • Base level (LOD 0) contains the original meshlets
  • Each subsequent level simplifies and re-clusterizes the geometry
  • Groups link clusters to their simplified parent representation

GPU selection uses screen-space error to pick the appropriate LOD level per cluster, with dithered transitions for smooth blending.

Definition at line 45 of file ClusterLodGenerator.h.

Member Function Documentation

◆ computeBoundingSphere()

glm::vec4 EngineCore::ClusterLodGenerator::computeBoundingSphere ( const std::vector< Vertex > & vertices,
const std::vector< uint32_t > & indices )
staticprivate

Compute bounding sphere for a set of vertices.

Definition at line 17 of file ClusterLodGenerator.cpp.

Referenced by generate().

Here is the caller graph for this function:

◆ computeMeshletBoundingSphere()

glm::vec4 EngineCore::ClusterLodGenerator::computeMeshletBoundingSphere ( const std::vector< Vertex > & vertices,
const meshopt_Meshlet & meshlet,
const std::vector< uint32_t > & meshletVertices )
staticprivate

Compute bounding sphere for a meshlet.

Definition at line 43 of file ClusterLodGenerator.cpp.

Referenced by generate().

Here is the caller graph for this function:

◆ generate()

Ecs::LodHierarchyResult EngineCore::ClusterLodGenerator::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 = {} )
static

Generate LOD hierarchy from mesh geometry.

Parameters
verticesInput vertex data
indicesInput index data
baseMeshletsBase level meshlets (already generated)
baseMeshletVerticesMeshlet vertex indices
baseMeshletTrianglesMeshlet triangle indices
configGeneration configuration
Returns
LOD hierarchy result with all clusters and groups

Definition at line 183 of file ClusterLodGenerator.cpp.

References Ecs::LodHierarchyResult::baseLevelClusterCount, EngineCore::ClusterLodData::boundsPositionAndRadius, Ecs::LodHierarchyResult::clusters, computeBoundingSphere(), computeMeshletBoundingSphere(), EngineCore::Debug, EngineCore::ClusterGroupData::depth, EngineCore::ClusterLodData::error, EngineCore::ClusterLodGenerator::LodLevelData::error, generateLodLevel(), Ecs::LodHierarchyResult::groups, EngineCore::ClusterLodGenerator::LodLevelData::indices, EngineCore::Info, Ecs::LodHierarchyResult::lodLevelCount, LogLOD, EngineCore::LodGenerationConfig::maxLodLevels, EngineCore::LodGenerationConfig::maxTrianglesPerCluster, Ecs::LodHierarchyResult::meshletData, EngineCore::ClusterLodData::meshletIndex, Ecs::MeshletData::meshlets, EngineCore::ClusterLodGenerator::LodLevelData::meshlets, EngineCore::ClusterLodGenerator::LodLevelData::meshletTriangles, EngineCore::ClusterLodGenerator::LodLevelData::meshletVertices, EngineCore::LodGenerationConfig::minTrianglesForLod, Ecs::PackedTriangle::pack(), EngineCore::ClusterLodData::refinedGroupId, EngineCore::LodGenerationConfig::simplificationRatio, EngineCore::ClusterGroupData::simplifiedBoundsPositionAndRadius, EngineCore::ClusterGroupData::simplifiedError, EngineCore::LodGenerationConfig::targetError, Ecs::UnpackedMeshletData::triangles, Ecs::LodHierarchyResult::unpackedData, Ecs::UnpackedMeshletData::vertices, EngineCore::ClusterLodGenerator::LodLevelData::vertices, and VS_LOG.

Here is the call graph for this function:

◆ generateLodLevel()

ClusterLodGenerator::LodLevelData EngineCore::ClusterLodGenerator::generateLodLevel ( const std::vector< Vertex > & srcVertices,
const std::vector< uint32_t > & srcIndices,
size_t targetIndexCount,
float targetError,
size_t maxVerticesPerMeshlet,
size_t maxTrianglesPerMeshlet )
staticprivate

The documentation for this class was generated from the following files: