Jump to content
  • Advertisement
Sign in to follow this  
lpcstr

View space vs screen space

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
View space is a 3d space in which you (ie. the camera) is at the origin and all the things you draw are in the right spot relative to your camera.

From view space, you then get into screen (or projection space) which is 2d and is literally what you see on the screen. A small 3d object might end up being a couple colored pixels in screen space near 150/100 on the screen.

Don't have anymore time, hope this makes it clear!

Share this post


Link to post
Share on other sites
Still a little confused. Especially when I hear about z-buffers either being in screen space or view space.

Share this post


Link to post
Share on other sites
Not sure where you heard about that, buffers themselves aren't "in" a space ever, the things that get drawn to them are. The z-buffer is, in all normal cases, linked to the back buffer (ie. what you get to see on your screen), as it stores the depth of what gets drawn, every pixel. The vertices of all the models, environments, particles (ie. all renderables) that you draw to the screen are transformed from their original space (I refer to that as model space), to world space (which positions them in your world), to view space (which positions your view, your camera, in the world) and then to screen space (which transforms the 3D scene you're looking at into actual pixels on your flat, 2D screen surface). So, by that logic, the contents of the z-buffer are always in screen space.

Share this post


Link to post
Share on other sites
It's about how the numbers are represented.


In view space, it is as if everything is around you, with your camera as the center of the universe. So, if an object is at X = 300 and you are looking it at X = 295; then this object in view space is at X = 5

In other words, moving the camera 295 units is the same as moving everything else -295 units.


Screen space is a slightly different, and is related on how triangle rasterization works. Your monitor goes from -1 to 1 in both X and Y (Z goes from 0 to 1 in Direct3D, and from -1 to 1 in OpenGL). Everything that is "inside your monitor" (aka. you can actually see it in screen) must be between X = -1 and X = 1.
X = -1 means it's in the left, while X = 1 it's in the right; while X = 0 it's in the center.
In Direct3D Z = 0 means it's right in front of you, Z = 1 is exactly at the far clipping plane


In the example about the object being at X = 5 in view space, in screen space it will depend on some factors (see projection if you're interested in the math) which will throw some number (i.e. let's say X = 500) then divided by the screen resolution (i.e. 1280x720) X = 500 / 1280 = 0.39
Since 0.39 is in the [-1; 1] range, it will be rendered (of course all Y & Z values must also be within valid ranges).

I hope this clears it up.

Share this post


Link to post
Share on other sites

I was reading this article: http://www.humus.name/index.php?ID=255

where it says:


While W is linear in view space it's not linear in screen space. Z, which is non-linear in view space, is on the other hand linear in screen space.


This is where I became confused.
[/quote]

Oh I see, it's not that the Z-Buffer is "in screen space"; but rather the values we write to the Z-Buffer are in screen space. It's perfectly possible to write W-like values to the Z Buffer but you have to do some math tricks

W-Buffer gave this on hardware automatically, but is now deprecated.




Edit: By saying "linear in screen space" he means that for a given triangle, for example,

  • at X = 0 Z = 0.5
  • at X = 0.5 Z = 0.75
  • at X = 1 Z = 1However, when looking XY from view space (but Z from screen space, which is a very common way to think of it) then:

    • at X = 290 Z = 0.5
    • at X = 315 Z = 0.75
    • at X = 1055 Z = 1That's what the article was trying to say. This is probably intermediate to advanced stuff though; not the best place to start.

Share this post


Link to post
Share on other sites
In the world you could say, This guy is north of the equation. If you are on the north pole looking at the south pole, in view space, the equator is north of YOU (or forward from you). As you change your orientation and view the world from diffferent directions and positions, a box can change from being in front of you, to being behind you. The view changes as the viewer (you) changes. In screen space, we are talking about physical pixels on your pc screen.

So world space: GPS coordinate from sattelite
View space: What is a hikers left direction while he is currently walking.
Screen space: What pixel am I dealing with in regards to drawing something.

The article itself is saying that when I take something from world, put it relative to the viewer and then if its in the viewers line of sight, it will draw. It takes a 3D Coordinate relative to the viewer and plops it to a pixel value from 0,0 to width,height of your screen. When doing that, the 3D coordinate goes to 2D, with the z component not mapping as would the other 2 components. It is honestly not that important to know. To know more you would have to try and figure out how a projection matrix works.

Share this post


Link to post
Share on other sites
Hidden

...but rather the values we write to the Z-Buffer are in screen space.


that's the part I don't understand :unsure:

Share this post


Link to post
If I understand this correctly, then he's saying that the z values when projected to the screen, are linear across the actual 2d image. I guess this allows for easy hardware interpolation, since is basically just a simple 2d gradient?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!