Jump to content

  • Log In with Google      Sign In   
  • Create Account


Vertices gets distorted camera is far away in the world


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 RyxiaN   Members   -  Reputation: 137

Like
0Likes
Like

Posted 19 January 2012 - 11:23 AM

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"

Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2338

Like
0Likes
Like

Posted 20 January 2012 - 03:48 AM

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!

#3 RyxiaN   Members   -  Reputation: 137

Like
0Likes
Like

Posted 20 January 2012 - 06:41 AM

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS