Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you determine the view-up vector?

This is an excerpt from Fundamentals of Computer Graphics by Peter Shirley. On Page 114 (in the 3rd edition it reads:

We'd like to be able to change the viewpoint in 3D and look in any direction. There are a multitude of conventions for specifying viewer position and orientation. We will use the following one:

  • the eye position e
  • the gaze direction g
  • the view-up vector t

The eye position is a location that the eye "sees from". If you think of graphics as a photographic process, it is the center of the lens. The gaze direction is any vector in the direction that the viewer is looking. The view-up vector is any vector in the plane that both bisects the viewer's head into right and left halves and points "to the sky" for a person standing on the ground. These vectors provide us with enough information to set up a coordinate system with origin e and uvw basis.....

The bold sentence is the one confusing me the most. Unfortunately the book provides only very basic and crude diagrams and doesn't provide any examples.

Does this sentence mean that all view-up vectors are simply (0, 1, 0)?

I tried it on some examples but it didn't quite match up with the given solutions (though it came close sometimes).

like image 217
CodyBugstein Avatar asked Jan 12 '23 07:01

CodyBugstein


2 Answers

Short answer: the view-up vector is not derived from other components: instead, it is a user input, chosen so as to ensure the camera is right-side up. Or, to put it another way, the view-up vector is how you tell your camera system what direction "up" is, for purposes of orienting the camera.


The reason you need a view-up vector is that the position and gaze direction of the camera is not enough to completely determine its pose: you can still spin the camera around the position/gaze axis. The view-up vector is needed to finish locking down the camera; and because people usually prefer to look at things right-side up, the view-up vector is conventionally a fixed direction, determined by how the scene is oriented in your coordinate space.

In theory, the view-up vector could be in any direction, but in practice "up" is usually a coordinate direction. Which coordinate is "up" is a matter of convention: in your case, it appears the Y-axis is "up", but some systems prefer the Z-axis.

That said, I will reiterate: you can choose pretty much any direction you want. If you want your first-person POV to "lean" (e.g., to look around a corner, or to indicate intoxication), you can tweak your view-up vector to accomplish this. Also, consider camera control in a game like Super Mario Galaxy...

like image 108
comingstorm Avatar answered Jan 20 '23 23:01

comingstorm


I took a graphics class last year, and I'm pretty rusty. I referenced some old notes, so here goes.

I think that bolded line is just trying to explain what the view-up vector (VUP) would mean in one case for sake of introduction, not what it necessarily is in all cases. The wording is a bit odd; here's a rewording: "Consider a person standing on the ground. VUP in that case would be the vector that bisects the viewer's head and points to the sky."

To determine a standard upward vector, do the following:

  1. Normalize g.
  2. g_norm x (0,1,0) gives you view-right, or the vector to the right of your camera view
  3. view-right x g gives you VUP.

You can then apply a rotation if you wish to do so.

like image 40
defect Avatar answered Jan 20 '23 22:01

defect