sotrh / learn-wgpu

Guide for using gfx-rs's wgpu library.
https://sotrh.github.io/learn-wgpu/
MIT License
1.48k stars 258 forks source link

Vertex jittering when a object is far from the origin #554

Open Khalzz opened 3 months ago

Khalzz commented 3 months ago

Im doing a game with wgpu while learning from the learn-wgpu tutorials and im getting a problem when moving an object far from the 0,0,0 origin point, i dont know if it might be because i missed something or i did something wrong.

The problem is that the far i am from the origin, the more distorted or jittery the vertexes look (it might be another reason on why thos elements looks like that but i think it might be the vertexes moving randomly), i tested some things like making the calculations as a f64 and then turning the values to f32 for the shader or changing the zfar and znear values of the camera.

The only thing that changed something was the znear, but the problem is that if there is something too close to the camera it disappears and is something i dont want it to happen.

If someone had the same problem or haves it i would like to know.

WGPU: v0.18.0 SDL2: v0.36 Source code with the error: https://github.com/Khalzz/Project-Skies

https://github.com/sotrh/learn-wgpu/assets/63627567/f82ca36c-0480-48af-bcdd-ddf380fe9e76

sotrh commented 2 months ago

How far from the origin are we talking?