Vertices gets distorted camera is far away in the world

This topic is 2521 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello there! I began working on a project a few weeks ago, where I wanted to implement "infinite" terrain, constantly streaming data from the harddrive. I have a free-view-camera, the code for updating the view matrix looks like this:

public void Update(Clock clock) { HandleInput(clock); var rotation = Matrix.RotationYawPitchRoll(yaw, pitch, 0); right = Vector3.TransformCoordinate(Vector3.UnitX, rotation); up = Vector3.TransformCoordinate(Vector3.UnitY, rotation); forward = Vector3.TransformCoordinate(Vector3.UnitZ, rotation); view = Matrix.LookAtLH(position, position + forward, up); }

This code works perfectly when the camera is near origo (0, 0, 0). But as soon as I get further away, at distances such as (5000, 10, 5000) the rotation of the camera starts acting a bit odd. The vertices looks distorted and sort of moves around a bit when you rotate, and sometimes the camera takes big rotation jumps, without reason. Hard to explain, and even harder to show with pictues. Hope you understand!

Is there something I have overlooked or is it "supposed" to happen when you're at these kind of distances away from origo?

Not sure if it matters, but I'm working with DirectX 11 in SlimDX. Thanks in advance!

EDIT :
Typo

EDIT 2 :
Title is supposed to be "Vertices gets distorted when camera is far away in the world"

Share on other sites
Hi,

Sounds like floating point accuracy issue. I assume that farther you are, bigger anomalies you get?

You should keep your world as small as suits your needs. Also keep the coordinates around (0,0,0) ie. (-2000,-2000,-2000) to (2000,2000,2000) instead of (0,0,0) to (4000,4000,4000).

Keep in mind that it doesn't prevent you having "infinite terrain". You just need to keep the things you draw not too far from origo.

Cheers!

Share on other sites
Yeah, I figured it could be some floating point errors. I also realized I wasn't (5000, 0, 5000) far off in the distance, I was (500.000, 0, 500.000). Don't ask me why. (:
But allright, so I guess I should offset everything then? I'm currently having 5*5 patches that are visible to the player, where the camera is in the center obviously. If I pass over from one patch to the next, I could offset everything the length of one patch back, and still render at origo? I'll give it a try.

Thanks!

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633724
• Total Posts
3013556
×