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);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"id": "bworld:acacia_leaves",
|
||||
"textures": "bworld:acacia_leaves",
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"color": "#80a755"
|
||||
},
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"id": "bworld:cherry_leaves",
|
||||
"textures": "bworld:cherry_leaves",
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"color": "foliage"
|
||||
},
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"color": "foliage"
|
||||
},
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"id": "bworld:spruce_leaves",
|
||||
"textures": "bworld:spruce_leaves",
|
||||
"render_layer": "cutout",
|
||||
"cull_same": true,
|
||||
"light_opacity": 1,
|
||||
"mining": {
|
||||
"toughness": 3,
|
||||
|
||||
Reference in New Issue
Block a user