Skip to content
Draft
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
b34a5ba
lod tests
Oct 13, 2024
9c6c08e
trying lod stuff
Oct 13, 2024
50a34d3
trying lod stuff
Oct 13, 2024
cee817b
trying lod stuff
Nov 8, 2024
fb5479e
Merge branch 'master' of https://github.com/minetest/minetest
Nov 8, 2024
89acd64
lod experiments
Dec 29, 2024
68aad86
corrected merge conflicts
Dec 29, 2024
0367966
added bandaid lods
Jan 4, 2025
7bb2524
exponential size scaling for lods reduced to linear
Mar 31, 2025
01de3d1
added client side lod meshes
Apr 8, 2025
749d251
fixed lod lighting
Apr 8, 2025
2b71caf
merged luanti 5.11.0
Apr 8, 2025
e429bd8
fixed edge cases
Apr 8, 2025
c8ceb27
improved lod performance through refactoring
Apr 9, 2025
121a94f
fixed lod lighting in caves
Apr 9, 2025
206cf4c
fixed lod UVs; changed the default settings
Apr 10, 2025
c8985b1
re enabled lod multithreading
Apr 10, 2025
78e81fc
added blocky lods
Apr 11, 2025
baefe7c
some code clean up
Apr 14, 2025
27007d0
fixed holes in lods
Apr 14, 2025
a792a8a
fixed lod lighting
Apr 17, 2025
07ecadb
fixed lod uvs
Apr 18, 2025
7cba51d
added lod slanted setting
Apr 18, 2025
5dd28c8
re added leaves to render on slantes lods
Apr 18, 2025
9317582
1x1x1 lods are shown again to avoid holes in the world
Apr 19, 2025
333265a
removed duplicate multithreading from lods
Apr 20, 2025
8118817
correctly centered lods on current pos if using larger mesh sizes
Apr 21, 2025
c26cf7b
minor lod fixes
Apr 25, 2025
93de028
fixed water rendering as wrong kind of lod
Apr 26, 2025
3a0a4f1
skipped rendering small quads on larger lods
Apr 28, 2025
1b55794
changed slanted threshold and fixed skipping of still large enough lods
Apr 29, 2025
8300153
Fixed simple leaves not showing on lods
May 2, 2025
e00b7f7
Added minimum lod setting
May 2, 2025
f15c601
Added minimum lod setting
May 3, 2025
0a6daa2
Changed LOD defaults
May 3, 2025
ca2a874
Changed near LOD calcs to facilitate future greedy meshing
May 3, 2025
04270ca
Fixed lod overflow issues
May 3, 2025
abfb28e
Some cleanup and removed traces of materialless branch
May 7, 2025
fd6fc0b
More LOD cleanup and performance improvement for close up water
May 10, 2025
55ceb90
Added greedy meshing to lods
May 26, 2025
6b91853
Monoblocks: optimize blocks that contain a single type of node
lhofhansl May 17, 2025
da4ff12
Check for mono-block after copyTo
lhofhansl May 17, 2025
5d9ce24
Make sure monoblocks account for all node params
lhofhansl May 18, 2025
3d3854d
Review comments
lhofhansl May 20, 2025
5a7caa5
speed up getNode memory access
lhofhansl May 20, 2025
a374f32
getBlockNodeIdMapping signature
lhofhansl May 20, 2025
06d9e33
track memory correctly
lhofhansl May 20, 2025
fa46f50
style
lhofhansl May 20, 2025
80f871c
loose ends and a unit test
lhofhansl May 22, 2025
22569a0
slight improvement
lhofhansl May 26, 2025
f5a5f8c
address review
lhofhansl May 31, 2025
5277ae7
Use unique_ptr and std::copy
lhofhansl May 31, 2025
a04c00c
allow copy to vmanip directly from a mono-block
lhofhansl Jun 1, 2025
7054cc1
hoist is_mono_block out of serialization loop
lhofhansl Jun 5, 2025
a27046d
Start every block as monoblock, and set m_is_mono_block in reallocate
lhofhansl Jun 13, 2025
d5bb8e1
minor cleanups
lhofhansl Jun 17, 2025
8c961f7
test fix/improvement
lhofhansl Jun 17, 2025
14026bc
alignment
lhofhansl Jun 18, 2025
13aa2e1
review comments
lhofhansl Jun 21, 2025
ad60bcd
start blocks out a expanded block (not monoblocks)
lhofhansl Jun 21, 2025
980f01f
slight improvements, shrink also when deserializing from network
lhofhansl Jun 28, 2025
c8c5ca9
more greedy meshing attempts
Jun 29, 2025
0ceaaa6
greedy mesher uses u64 instead of bitsets now
Jun 29, 2025
abbd4f7
attempted but failed lighting on greedy meshes
Jul 4, 2025
3e58ba9
Merge tag '5.12.0' of https://github.com/minetest/minetest into conve…
Jul 4, 2025
2d74406
fixed overflow on mesh grid size 16
Jul 5, 2025
6cf9ebc
merge monoblocks
Jul 5, 2025
f99f6a3
fixed overflow on mesh grid size 16 part 2
Jul 6, 2025
e6241eb
added lod resolution
Jul 10, 2025
d50fd7c
increased view range to 8k
Jul 11, 2025
c80f3f5
moved greedy lod generation to its own function
Jul 13, 2025
dc06267
moved greedy lod generation to its own function yet again
Jul 18, 2025
6e24dc8
greedy mesher only draws most common node types
Jul 20, 2025
81e99f7
used u64 instead of std::bitset
Jul 22, 2025
5227e2a
further progress using u64 instead of std::bitset
Jul 25, 2025
c8ff66c
finished switching to u64 for bitsets
Jul 26, 2025
0a07d39
i dont remember what i did here
Sep 25, 2025
0eb1e80
lod generation simplified
Oct 2, 2025
6cfe22e
fixed lod lighting
Oct 7, 2025
93c207a
fixed sides of lod not rendering
Oct 7, 2025
8d842ec
more lod sampling and profiling
Oct 9, 2025
a25aa3d
actually added profiling
Oct 9, 2025
d935e97
excluded padding node in lod generation, only generate minimap for no…
Oct 10, 2025
f93b28d
Merge tag '5.14.0' of https://github.com/minetest/minetest into conve…
Oct 10, 2025
c15577e
flattened some datastructures
Oct 11, 2025
5d67514
fixed segfault due to getNodeUnsafe, simplified some multiplications …
Oct 11, 2025
f2cdc91
calc decimal places on mesh gen duration
Oct 11, 2025
ca7e818
more minor lod improvements
Oct 12, 2025
0cf0cba
removed slanted lods
Oct 12, 2025
231a9b7
started mono material lods
Oct 14, 2025
a51c750
mono material lod depend on node color
Oct 17, 2025
a6f34c5
removed space formatting
Oct 17, 2025
9a2f7fa
added lod mono material setting
Oct 17, 2025
fd4d2ce
minor clean ups and naming conventions
Oct 17, 2025
bb6e699
Merge branch 'master' of https://github.com/minetest/minetest into co…
Oct 18, 2025
346b6f3
Moved lod mesh gen to its own file
Oct 19, 2025
43016c2
removed merge error
Oct 19, 2025
8053da1
fixed textureless lighting by extending the shader/materials
Oct 20, 2025
81a4b01
fixed incorrect indent and removed unused code
Oct 22, 2025
8ff0789
added tile colors for use in textureless lod meshes that dont depend …
Oct 22, 2025
d9652b0
reordered lod directions to be in line with the rest of the engine
Oct 22, 2025
5c65474
replaced magic number with a constant
Oct 23, 2025
386b17d
fixed some nuclear level brain farts
Oct 23, 2025
7e82666
added some comments
Oct 23, 2025
89f800c
moved lod calculation outside of mesh gen thread
Oct 28, 2025
085f2dc
reimplemented std::__countr_zero in software to support other compilers
Oct 29, 2025
3b1cedd
used __builtin_ctzll instead
Oct 29, 2025
fe7e122
fixed lods not being aligned with chunks
Oct 29, 2025
a6c648c
fixed typo
Oct 30, 2025
2839bd1
Merge branch 'master' of https://github.com/minetest/minetest into co…
Nov 3, 2025
7be62a3
removed textureless material
Nov 3, 2025
13fb67a
always include glasslikes in lods to be more consistent
Nov 3, 2025
00ac531
hopefully be portable. dont have all the compilers to test, so have t…
Nov 3, 2025
7151710
added mesh nodes to lods as regular nodes
Nov 3, 2025
731e4b5
renamed mono material to textureless to be more consistent
Nov 6, 2025
d95655e
added a setting to enable/disable LODs altogether
Nov 6, 2025
f2b6d47
replaced spaces with tabs
Nov 6, 2025
59de5e6
fixed wrong whitespace and removed unused code
Nov 7, 2025
8fdf597
fixed usage of _BitScanForward64
Nov 7, 2025
885b0b9
fixed even more wrong indents
Nov 7, 2025
92a9bfe
Merge branch 'master' of https://github.com/minetest/minetest into co…
Nov 7, 2025
40e338c
fixed a whole lot of merge mistakes
Nov 7, 2025
25c3c65
even more wrong whitespace
Nov 7, 2025
3445571
even more wrong whitespace
Nov 7, 2025
0f158fb
even more wrong whitespace
Nov 7, 2025
4902bb7
hope and pray i finally used _BitScanForward64 correctly
Nov 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
491 changes: 491 additions & 0 deletions CMakeLists.txt.user

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,20 @@ viewing_range (Viewing range) int 190 20 4000
# to a non-default value.
undersampling (Undersampling) int 1 1 8

[**LOD]

# Distance of blocks, when LODs should kick in.
lod_threshold (LOD Threshold) int 20 10 50

# Quality of LODs from 1 (low) to 2 (high).
# At 1, the quality decreases at every distance where the LOD Threshold is doubled.
# At 2, the quality decreases at every distance where the LOD Threshold is doubled twice.
# Since this setting interacts with LOD Threshold, a lower quality can still look good if the threshold is sufficiently high.
lod_quality (LOD Quality) float 1.5 0.5 5

# LOD level at which they should be textureless
lod_color_threshold (LOD Color Threshold) int 2 1 5

[**3D]

# 3D support.
Expand Down
6 changes: 5 additions & 1 deletion client/shaders/nodes_shader/opengl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ void main(void)
vec3 color;
vec2 uv = varTexCoord.st;

vec4 base = texture2D(baseTexture, uv).rgba;
#ifdef TEXTURELESS
vec4 base = vec4(1); // white, so color is fully controlled by vertex color
#else
vec4 base = texture2D(baseTexture, uv).rgba;
#endif
// If alpha is zero, we can just discard the pixel. This fixes transparency
// on GPUs like GC7000L, where GL_ALPHA_TEST is not implemented in mesa,
// and also on GLES 2, where GL_ALPHA_TEST is missing entirely.
Expand Down
2 changes: 2 additions & 0 deletions irr/include/EMaterialTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ enum E_MATERIAL_TYPE
pack_textureBlendFunc (for 2D) or pack_textureBlendFuncSeparate (for 3D). */
EMT_ONETEXTURE_BLEND,

EMT_TEXTURELESS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pass this as a shader parameter, don't add a new material.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think i got a pretty ok idea of what this entails, but just wanna confirm it before putting in too much work.

  • add a new UniformSetter and implement whatever is necessary for a CachedPixelShaderSetting to pass a boolean
  • add an "isTextureless" attribute the driver
  • add another attribute like that to ISceneNode
  • set the driver attribute in drawAll if the node is textureless

Is this how its done or am i overlooking something simpler?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

way too complicated.

look into how ContentFeatures::updateTextures uses IShaderSource::getShader to pass the "use an array texture or not" information to the shader.
the textureless property can work exactly the same way.


//! This value is not used. It only forces this enumeration to compile to 32 bit.
EMT_FORCE_32BIT = 0x7fffffff
};
Expand Down
44 changes: 26 additions & 18 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ pkgs.mkShell {
env.LANG = "C.UTF-8";
env.LC_ALL = "C.UTF-8";

packages = [
pkgs.gcc
pkgs.cmake
pkgs.zlib
pkgs.zstd
pkgs.libjpeg
pkgs.libpng
pkgs.libGL
pkgs.luajit
pkgs.SDL2
pkgs.openal
pkgs.curl
pkgs.libvorbis
pkgs.libogg
pkgs.gettext
pkgs.gmp
pkgs.freetype
pkgs.sqlite
packages = with pkgs; [
gcc
cmake
zlib
zstd
libjpeg
libpng
libGL
luajit
SDL2
openal
curl
libvorbis
libogg
gettext
gmp
freetype
sqlite

mangohud
python313
python313Packages.fire
python313Packages.matplotlib
python313Packages.numpy
python313Packages.pandas
python313Packages.scipy
];
}
1 change: 1 addition & 0 deletions src/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(client_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/content_cao.cpp
${CMAKE_CURRENT_SOURCE_DIR}/content_cso.cpp
${CMAKE_CURRENT_SOURCE_DIR}/content_mapblock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lod_mapblock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/filecache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fontengine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/game.cpp
Expand Down
4 changes: 1 addition & 3 deletions src/client/clientmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)

// Mesh animation
if (pass == scene::ESNRP_SOLID) {
// 50 nodes is pretty arbitrary but it should work somewhat nicely
float distance_sq = camera_position.getDistanceFromSQ(mesh_sphere_center);
bool faraway = distance_sq >= std::pow(BS * 50 + mesh_sphere_radius, 2.0f);
bool faraway = block_mesh->m_lod == 0;

if (block_mesh->isAnimationForced() || !faraway ||
mesh_animate_count < (m_control.range_all ? 200 : 50)) {
Expand Down
5 changes: 4 additions & 1 deletion src/client/content_mapblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <SMesh.h>
#include <IMeshBuffer.h>

#include "profiler.h"

// Distance of light extrapolation (for oversized nodes)
// After this distance, it gives up and considers light level constant
#define SMOOTH_LIGHTING_OVERSIZE 1.0
Expand Down Expand Up @@ -1810,6 +1812,7 @@ void MapblockMeshGenerator::drawNode()
void MapblockMeshGenerator::generate()
{
ZoneScoped;
ScopeProfiler sp(g_profiler, "Client: Mesh Making Regular", SPT_AVG);

for (cur_node.p.Z = 0; cur_node.p.Z < data->m_side_length; cur_node.p.Z++)
for (cur_node.p.Y = 0; cur_node.p.Y < data->m_side_length; cur_node.p.Y++)
Expand All @@ -1818,4 +1821,4 @@ void MapblockMeshGenerator::generate()
cur_node.f = &nodedef->get(cur_node.n);
drawNode();
}
}
}
36 changes: 2 additions & 34 deletions src/client/content_mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,11 @@
#pragma once

#include "nodedef.h"
#include <bitset>

struct MeshMakeData;
struct MeshCollector;

struct LightPair {
u8 lightDay;
u8 lightNight;

LightPair() = default;
explicit LightPair(u16 value) : lightDay(value & 0xff), lightNight(value >> 8) {}
LightPair(u8 valueA, u8 valueB) : lightDay(valueA), lightNight(valueB) {}
LightPair(float valueA, float valueB) :
lightDay(core::clamp(core::round32(valueA), 0, 255)),
lightNight(core::clamp(core::round32(valueB), 0, 255)) {}
operator u16() const { return lightDay | lightNight << 8; }
};

struct LightInfo {
float light_day;
float light_night;
float light_boosted;

LightPair getPair(float sunlight_boost = 0.0f) const
{
return LightPair(
(1 - sunlight_boost) * light_day
+ sunlight_boost * light_boosted,
light_night);
}
};

struct LightFrame {
f32 lightsDay[8];
f32 lightsNight[8];
bool sunlight[8];
};

class MapblockMeshGenerator
{
public:
Expand Down Expand Up @@ -168,4 +136,4 @@ class MapblockMeshGenerator
// common
void errorUnknownDrawtype();
void drawNode();
};
};
4 changes: 2 additions & 2 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2339,8 +2339,8 @@ void Game::increaseViewRange()
s16 range_new = range + 10;
s16 server_limit = sky->getFogDistance();

if (range_new >= 4000) {
range_new = 4000;
if (range_new >= 8000) {
range_new = 8000;
std::wstring msg = server_limit >= 0 && range_new > server_limit ?
fwgettext("Viewing range changed to %d (the maximum), but limited to %d by game or mod", range_new, server_limit) :
fwgettext("Viewing range changed to %d (the maximum)", range_new);
Expand Down
Loading