Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for near plane distance. #6395

Merged
merged 2 commits into from Oct 7, 2017
Merged

Add setting for near plane distance. #6395

merged 2 commits into from Oct 7, 2017

Conversation

basicer
Copy link
Contributor

@basicer basicer commented Sep 8, 2017

One weaker GPUs, such as the ones found in cheap tablets, you can sometimes see z-fighting between entities even when they are 1 node apart at larger distances ~200 nodes. (Granted I had increased the active_block_range before this happened). This may be because they are using 16 bit depth buffers, but I'm not sure on the exact cause.

Setting the near plane to 2.5 (0.25 blocks) fixed this for me by pushing out some of the depth buffer accuracy toward farther away objects. The only down side of this I have found is when in no-clip mode, objects clip a little sooner.

@basicer basicer changed the title Allow setting for near plane distance. Add setting for near plane distance. Sep 8, 2017
@paramat paramat added @ Client / Audiovisuals Feature ✨ PRs that add or enhance a feature labels Sep 8, 2017
@@ -532,6 +532,9 @@ pause_fps_max (FPS in pause menu) int 20
# View distance in nodes.
viewing_range (Viewing range) int 100 20 4000

# Near plane distance in nodes.
Copy link
Member

@sfan5 sfan5 Sep 8, 2017

Choose a reason for hiding this comment

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

maybe add a note here that you should usually not need to change this value + the example you mentioned (=0.25 on mobile devices)

@paramat
Copy link
Contributor

paramat commented Sep 8, 2017

Interesting, might be useful for other reasons, but cheap devices will not be using 'active block range' that large, because that also vastly increases ABM load which is already heavy.
So, what other use does this have?
Did you know that we already shift the world every 200 nodes travelled to minimise precision depth errors? Before that most of the world suffered depth errors.

@basicer
Copy link
Contributor Author

basicer commented Sep 12, 2017

It fixes quite a few problems on these weaker devices. For comparison here is fairly large entity drawn with the default active block range. The large green area is supposed be a PCB, and the black box is a cube "chip" on top of it. Here are renderings from an Raspberry Pi 3 at near plane 0.1 vs 0.25. Notice how the cube gets a weird bottom edge with the default near plane.

screenshot_20170912_033332
screenshot_20170912_033418

@paramat
Copy link
Contributor

paramat commented Sep 12, 2017

Ok useful.

@juhdanad
Copy link
Contributor

There should be a limit. Too large values can be used for x-ray vision. And non-positive values are invalid.

src/camera.cpp Outdated
@@ -551,7 +551,7 @@ 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(near_plane * BS);
m_cameranode->setNearValue(MYMIN(MYMAX(0, near_plane), 0.5) * BS);
Copy link
Contributor

@paramat paramat Sep 14, 2017

Choose a reason for hiding this comment

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

We have functions for this, either rangelim(near_plane, 0.0f, 0.5f) or maybe std::clamp(...) not sure which.
Either way please state as floats with a 'f'.

- Add more details to near_plane setting.
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

LGTM

@nerzhul nerzhul merged commit 3c93a56 into minetest:master Oct 7, 2017
sfan5 pushed a commit that referenced this pull request Nov 19, 2017
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
@sfan5 sfan5 mentioned this pull request Dec 5, 2017
sfan5 pushed a commit that referenced this pull request Dec 5, 2017
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
t0ny2 pushed a commit to t0ny2/minetest that referenced this pull request Jan 23, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
sfan5 pushed a commit that referenced this pull request Feb 2, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
sfan5 pushed a commit that referenced this pull request Feb 3, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
sfan5 pushed a commit that referenced this pull request Apr 21, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
sfan5 pushed a commit that referenced this pull request May 13, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
SmallJoker pushed a commit that referenced this pull request Jun 3, 2018
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 11, 2019
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 23, 2019
* Allow setting the near plane

* - Add near_plane limit of 0.5 to prevent x-ray.
- Add more details to near_plane setting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants