Add setting for near plane distance. (#6395)
authorRob Blanckaert <basicer@basicer.com>
Sat, 7 Oct 2017 13:11:48 +0000 (09:11 -0400)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.

builtin/settingtypes.txt
src/camera.cpp
src/defaultsettings.cpp

index 0da66750a7e57c94ef84574fdabceeefa1038a55..ddb0afacda365f9c83e156fb2cf1b990d02678df 100644 (file)
@@ -476,6 +476,12 @@ pause_fps_max (FPS in pause menu) int 20
 #    View distance in nodes.
 viewing_range (Viewing range) int 100 20 4000
 
+#   Camera near plane distance in nodes, between 0 and 0.5
+#   Most users will not need to change this.
+#   Increasing can reduce artifacting on weaker GPUs.
+#   0.1 = Default, 0.25 = Good value for weaker tablets.
+near_plane (Near plane) float 0.1 0 0.5
+
 #    Width component of the initial window size.
 screenW (Screen width) int 800
 
index 52a42a3a9e6bbb1d8c867c77de953b99d7a7c01f..6957508cceecc8b8321786977a9ca5226ad37a43 100644 (file)
@@ -487,7 +487,9 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
 void Camera::updateViewingRange()
 {
        f32 viewing_range = g_settings->getFloat("viewing_range");
+       f32 near_plane = g_settings->getFloat("near_plane");
        m_draw_control.wanted_range = viewing_range;
+       m_cameranode->setNearValue(rangelim(near_plane, 0.0f, 0.5f) * BS);
        if (m_draw_control.range_all) {
                m_cameranode->setFarValue(100000.0);
                return;
index 3378e8b4a894cbfc52fade73891c14addbbc717d..181a12b5e67a8b3809722a9219c05ba9d58e8632 100644 (file)
@@ -125,6 +125,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("fps_max", "60");
        settings->setDefault("pause_fps_max", "20");
        settings->setDefault("viewing_range", "100");
+       settings->setDefault("near_plane", "0.1");
        settings->setDefault("screenW", "800");
        settings->setDefault("screenH", "600");
        settings->setDefault("autosave_screensize", "true");