Optimize rendering a lil

This commit is contained in:
2026-10-02 19:35:16 -03:00
parent 4397bf2c90
commit 1511338a23
8 changed files with 15 additions and 0 deletions
+8
View File
@@ -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);
+1
View File
@@ -4,6 +4,7 @@
"id": "bworld:acacia_leaves",
"textures": "bworld:acacia_leaves",
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -7,6 +7,7 @@
"color": "#80a755"
},
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -4,6 +4,7 @@
"id": "bworld:cherry_leaves",
"textures": "bworld:cherry_leaves",
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -4,6 +4,7 @@
"id": "bworld:dark_oak_leaves",
"textures": "bworld:dark_oak_leaves",
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -7,6 +7,7 @@
"color": "foliage"
},
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -8,6 +8,7 @@
"color": "foliage"
},
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,
+1
View File
@@ -4,6 +4,7 @@
"id": "bworld:spruce_leaves",
"textures": "bworld:spruce_leaves",
"render_layer": "cutout",
"cull_same": true,
"light_opacity": 1,
"mining": {
"toughness": 3,