mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 22:22:23 +01:00
Allow to disable transparency sorting entirely (#15101)
This commit is contained in:
parent
0c4f03d9a5
commit
f23d7459b3
@ -1854,8 +1854,9 @@ shader_path (Shader path) path
|
|||||||
# OpenGL is the default for desktop, and OGLES2 for Android.
|
# OpenGL is the default for desktop, and OGLES2 for Android.
|
||||||
video_driver (Video driver) enum ,opengl,opengl3,ogles2
|
video_driver (Video driver) enum ,opengl,opengl3,ogles2
|
||||||
|
|
||||||
# Distance in nodes at which transparency depth sorting is enabled
|
# Distance in nodes at which transparency depth sorting is enabled.
|
||||||
# Use this to limit the performance impact of transparency depth sorting
|
# Use this to limit the performance impact of transparency depth sorting.
|
||||||
|
# Set to 0 to disable it entirely.
|
||||||
transparency_sorting_distance (Transparency Sorting Distance) int 16 0 128
|
transparency_sorting_distance (Transparency Sorting Distance) int 16 0 128
|
||||||
|
|
||||||
# Radius of cloud area stated in number of 64 node cloud squares.
|
# Radius of cloud area stated in number of 64 node cloud squares.
|
||||||
|
@ -1311,9 +1311,9 @@ void ClientMap::updateTransparentMeshBuffers()
|
|||||||
ScopeProfiler sp(g_profiler, "CM::updateTransparentMeshBuffers", SPT_AVG);
|
ScopeProfiler sp(g_profiler, "CM::updateTransparentMeshBuffers", SPT_AVG);
|
||||||
u32 sorted_blocks = 0;
|
u32 sorted_blocks = 0;
|
||||||
u32 unsorted_blocks = 0;
|
u32 unsorted_blocks = 0;
|
||||||
|
bool transparency_sorting_enabled = m_cache_transparency_sorting_distance > 0;
|
||||||
f32 sorting_distance = m_cache_transparency_sorting_distance * BS;
|
f32 sorting_distance = m_cache_transparency_sorting_distance * BS;
|
||||||
|
|
||||||
|
|
||||||
// Update the order of transparent mesh buffers in each mesh
|
// Update the order of transparent mesh buffers in each mesh
|
||||||
for (auto it = m_drawlist.begin(); it != m_drawlist.end(); it++) {
|
for (auto it = m_drawlist.begin(); it != m_drawlist.end(); it++) {
|
||||||
MapBlock *block = it->second;
|
MapBlock *block = it->second;
|
||||||
@ -1323,13 +1323,19 @@ void ClientMap::updateTransparentMeshBuffers()
|
|||||||
|
|
||||||
if (m_needs_update_transparent_meshes ||
|
if (m_needs_update_transparent_meshes ||
|
||||||
blockmesh->getTransparentBuffers().size() == 0) {
|
blockmesh->getTransparentBuffers().size() == 0) {
|
||||||
|
bool do_sort_block = transparency_sorting_enabled;
|
||||||
|
|
||||||
v3f mesh_sphere_center = intToFloat(block->getPosRelative(), BS)
|
if (do_sort_block) {
|
||||||
+ blockmesh->getBoundingSphereCenter();
|
v3f mesh_sphere_center = intToFloat(block->getPosRelative(), BS)
|
||||||
f32 mesh_sphere_radius = blockmesh->getBoundingRadius();
|
+ blockmesh->getBoundingSphereCenter();
|
||||||
f32 distance_sq = m_camera_position.getDistanceFromSQ(mesh_sphere_center);
|
f32 mesh_sphere_radius = blockmesh->getBoundingRadius();
|
||||||
|
f32 distance_sq = m_camera_position.getDistanceFromSQ(mesh_sphere_center);
|
||||||
|
|
||||||
if (distance_sq <= std::pow(sorting_distance + mesh_sphere_radius, 2.0f)) {
|
if (distance_sq > std::pow(sorting_distance + mesh_sphere_radius, 2.0f))
|
||||||
|
do_sort_block = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_sort_block) {
|
||||||
blockmesh->updateTransparentBuffers(m_camera_position, block->getPos());
|
blockmesh->updateTransparentBuffers(m_camera_position, block->getPos());
|
||||||
++sorted_blocks;
|
++sorted_blocks;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user