Optimize rendering a lil
This commit is contained in:
@@ -60,6 +60,14 @@ export class LevelRenderer {
|
||||
this.#visible.push(chunk);
|
||||
}
|
||||
}
|
||||
// near to far, like sodium, so what's in front fills the depth buffer first and the gpu can skip shading what's
|
||||
// behind it
|
||||
const distance_sq = (chunk: Chunk) => {
|
||||
const dx = (chunk.x + 0.5) * CHUNK_SIZE - camera.x;
|
||||
const dz = (chunk.z + 0.5) * CHUNK_SIZE - camera.z;
|
||||
return dx * dx + dz * dz;
|
||||
};
|
||||
this.#visible.sort((a, b) => distance_sq(a) - distance_sq(b));
|
||||
|
||||
set_current_texture(level.image.tex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user