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

If something falls into the depths, the near world will be clipped eventually #1207

Open
microaaron opened this issue Apr 27, 2022 · 14 comments

Comments

@microaaron
Copy link
Contributor

https://video.twimg.com/ext_tw_video/1519159159647719425/pu/vid/640x360/lMB3hiUIzGA8jQAs.mp4?tag=12

@andreasplesch
Copy link
Contributor

:) Try a fixed zFar/zNear with the Viewpoint ?

@microaaron
Copy link
Contributor Author

:) Try a fixed zFar/zNear with the Viewpoint ?

Yes, it's effective.

@microaaron
Copy link
Contributor Author

Does it need to be fixed?

By the way, according to X3D standard, zFar/zNear should be named farDistance/nearDistance.

@andreasplesch
Copy link
Contributor

andreasplesch commented Apr 28, 2022

That is new in the standard. But changing the names will break older scenes, and making both names work is a bit harder than it sounds.

X3D defines fixed distances. But for most situations dynamic, and automatic determinations are more robust.

@microaaron
Copy link
Contributor Author

microaaron commented Apr 29, 2022

I found the key codes:
var zNearLimit = zfar / this._zRatio;
Increasing zfar leads to the increase of zNearLimit.

@andreasplesch
Copy link
Contributor

I believe this is intentional for numerical precision reasons required for perspective projections. The ratio needs to stay reasonable, within a certain range.

@microaaron
Copy link
Contributor Author

microaaron commented Apr 29, 2022

Maybe it's not a bug, but this phenomenon is often not as expected.

@microaaron
Copy link
Contributor Author

What are the negative effects of large zFar and small zNear?

@andreasplesch
Copy link
Contributor

mrdoob/three.js#11755

is related. A solution would be to add support for the infinite projection matrix.

@andreasplesch andreasplesch changed the title If something falls into the depths, the whole world will be wiped in 5 minutes. If something falls into the depths, the near world will be clipped eventually Apr 30, 2022
@microaaron
Copy link
Contributor Author

Thanks.

@microaaron
Copy link
Contributor Author

is related. A solution would be to add support for the infinite projection matrix.

This seems to mean _zRatio is no longer meaningful, and inevitably leads to low precision.

@microaaron
Copy link
Contributor Author

microaaron commented May 8, 2024

As zfar increases, the precision decrease gradually converges. When zfar approaches infinity, the infinite projection matrix is obtained.

new x3dom.fields.SFMatrix4f(
        f / aspect, 0, 0, 0,
        0, f, 0, 0,
        0, 0, -1, -2 * near,
        0, 0, -1, 0
    );

Obviously, the precision is only affected by znear at this time.

@microaaron
Copy link
Contributor Author

Almost the same

@microaaron
Copy link
Contributor Author

microaaron commented May 8, 2024

I got it, the original intention of the design should be to improve distant details by increasing znear.
The infinite projection matrix does not improve the precision problem.The value of znear still requires trade-offs.
There is an improved way for webgpu: reversedZ.
But this is not suitable for webgl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants