Meshing and lighting per section

This commit is contained in:
2026-11-07 11:41:21 -03:00
parent 71cbf901a5
commit b726ce9695
21 changed files with 736 additions and 544 deletions
+9 -6
View File
@@ -98,8 +98,9 @@ export class DebugOverlay {
const level = client.level;
const level_renderer = client.game_renderer.level_renderer;
const { meshed, bytes } = this.#count_chunks(client);
text(`chunks: ${level.chunks.size} loaded, ${meshed} meshed, ${level_renderer.visible_chunks} in view`);
text(` ${level.dirty_count} waiting to mesh, ${level.meshes_in_flight} meshing`);
text(`chunks: ${level.chunks.size} loaded`);
text(` sections: ${meshed} with meshes, ${level_renderer.visible_sections} in view`);
text(` ${level.dirty_count} waiting to mesh, ${level.meshes_in_flight} requests meshing`);
text(` meshes: ${(bytes / 1024 / 1024).toFixed(1)} MB`);
text(`entities: ${level.entities.size} loaded, ${level_renderer.drawn_entities} in view`);
separator();
@@ -142,7 +143,7 @@ export class DebugOverlay {
);
}
// meshed chunks and what their meshes take on the gpu, once a second
// sections with meshes and what their meshes take on the gpu, once a second
#count_chunks(client: Client) {
const now = performance.now();
if (now - this.#chunk_stats_time < CHUNK_STATS_MS) return this.#chunk_stats;
@@ -150,9 +151,11 @@ export class DebugOverlay {
let meshed = 0;
let bytes = 0;
for (const chunk of client.level.chunks.values()) {
const meshes = Object.values(chunk.meshes);
if (meshes.length > 0) meshed += 1;
for (const mesh of meshes) bytes += mesh.vertex_buffer.size + (mesh.index_buffer?.size ?? 0);
for (const section of chunk.sections) {
const meshes = Object.values(section.meshes);
if (meshes.length > 0) meshed += 1;
for (const mesh of meshes) bytes += mesh.vertex_buffer.size + (mesh.index_buffer?.size ?? 0);
}
}
this.#chunk_stats = { meshed, bytes };
return this.#chunk_stats;