0

I have been working on a 3d-game-engine and I encountered a problem with shaking objects:

img

If the camera is rotated (not translated), then the objects start to shake. Furthermore, I noticed that after one orbit (it's a prototype of a space simulator) the shaking is as low as when I started the game. I assume the camera coordinates are almost at zero when the shaking is not that worse.

The camera is bound to the object so it should be unlikely that the shaking comes from the physical coordinates of the object that shake, because then the camera should shake, too.

I calculate the view-and-projection-matrix like this:

cameraAndProjectionMatrixSmallObjects = 
glm::perspective(glm::radians(70.f), 1.9f, 0.001f, 100.0f);*
glm::lookAt(worldPosition, heading + worldPosition, up);

I believe it could be a problem with floating-point-precision however if it is something like that I don't know how to solve it.

Spektre
  • 49,595
  • 11
  • 110
  • 380
Darius Duesentrieb
  • 837
  • 10
  • 20
  • It's normal to heading and if the heading is rotated then up will be rotated with the same matrix. – Darius Duesentrieb Jul 29 '17 at 18:45
  • @DariusDuesentrieb take a look here: [Is it possible to make realistic n-body solar system simulation in matter of size and mass?](https://stackoverflow.com/a/28020934/2521214). Use relative coordinates that will help a lot (translate meshes so (0.0.0) is camera position before passing to **OpenGL**). – Spektre Jul 31 '17 at 06:18
  • That is apparently the solution I searched for, maybe you could move this text to an answer, just so that I can declare this as solved? – Darius Duesentrieb Jul 31 '17 at 13:43

1 Answers1

1

Your objects are too far from world origin. GPUs work with limited precision float numbers and if you use big numbers the objects start to shake. Try scaling everything down of a factor of 1000. You can find a detailed description of this issue here.

abenci
  • 8,422
  • 19
  • 69
  • 134