HeapsIO / heaps

Heaps : Haxe Game Framework
http://heaps.io
MIT License
3.19k stars 337 forks source link

Z-fighting/"jiggling" just a couple of units away from the world origin #1167

Closed 10c8 closed 1 year ago

10c8 commented 1 year ago

I am having issues with z-fighting in meshes and "jiggling" with h3d.scene.Graphics as well as I move further from the origin point. I would expect this to happen on really large numbers, but the issues appear at X;Y as low as 700;700, getting worse as we move further.

The issue happens on heaps:git, with both hldx:git and hlsdl:git, on both Forward and PBR modes, and is reproducible with a World demo, altered to allow for camera movement.

Tested on Windows 10, with an NVIDIA RTX 3060 (driver version 537.34).

ncannasse commented 1 year ago

You might want to adjust your s3d.camera zNear/zFar for better depth buffer precision.

Le sam. 30 sept. 2023 à 01:04, William Fernandes @.***> a écrit :

I am having issues with z-fighting in meshes and "jiggling" with h3d.scene.Graphics as well as I move further from the origin point. I would expect this to happen on really large numbers, but the issues appear at X;Y as low as 700;700, getting worse as we move further.

The issue happens on heaps:git, with both hldx:git and hlsdl:git, on both Forward and PBR modes, and is reproducible with a World demo, altered to allow for camera movement.

Tested on Windows 10, with an NVIDIA RTX 3060 (driver version 537.34).

— Reply to this email directly, view it on GitHub https://github.com/HeapsIO/heaps/issues/1167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZXQEL5WQ7BJFVGTTPFKDX45HWLANCNFSM6AAAAAA5NC2YEM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

10c8 commented 1 year ago

I've tried testing different combinations of zNear/zFar properties to no success. The problem happens on a zNear/zFar of 0.02/4000.0 as well as 0.1/0.40.

ncannasse commented 1 year ago

If your depth range / objects size are in the centimeter and you're going far from it (relatively to the objects size) then you will get imprecision because of the limitation of the 32 bits float the GPU is using. In which case you need to change your s3d.x/y/z and your camera so all your objects absolute position remains within a range that does not lose precision (the floats are 64 bits on the CPU).

10c8 commented 1 year ago

Are you saying I should move the world around the player instead of the opposite?

ncannasse commented 1 year ago

Yes. Although I can be done in sequences and not continually. Everytime you cross X distance.

Le dim. 1 oct. 2023 à 21:57, William Fernandes @.***> a écrit :

Are you saying I should move the world around the player instead of the opposite?

— Reply to this email directly, view it on GitHub https://github.com/HeapsIO/heaps/issues/1167#issuecomment-1742184129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZXQFOSI3SI6747CUMWHDX5HDJ7ANCNFSM6AAAAAA5NC2YEM . You are receiving this because you modified the open/close state.Message ID: @.***>

10c8 commented 1 year ago

Anything I can do to minimize artifacts when doing so? I've been trying this for a while but every now and then after a "transition" the camera will render from the old position for a frame or so. Any way to keep the position shift in sync with the render? Thanks for the quick responses and support!