Sign in to follow this  
dwmitch

depth mapping

Recommended Posts

I was reading in some other threads about how depth mapping was used in the FFVII-FFIX games to render the player "behind" certain elements in the pre-rendered background. I've searched both this site and Google using the terms depth map, occlusion culling, and distance based selection (each search would lead me to a possible alternate term), but I haven't been able to find any information. Where would I go to learn about it, preferrably without having to buy any books or go to the commercial tutorial sites (i.e. pay $20 per to download a tutorial)?

Share this post


Link to post
Share on other sites
z-buffer. :)

Basically, when a pixel gets drawn, it also gets a z value, or distance value. Whenever a polygon gets translated to a bunch of pixels and gets drawn on the screen, the z value of each pixel is checked against the z value of the pixel already there - if there is any. If the new pixel is closer, it overwrites the old pixel. Otherwise, nothing changes. This z-buffer is then reset before the next frame is drawn.

I assume these games stored a z map for each background, or they simply cut the background up into multiple parts and rendered them closer or further away - which would essentially give different z values anyway. If there's no z-buffer, then the drawing order determines what is shown on top, obviously. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Captain P
z-buffer. :)

Basically, when a pixel gets drawn, it also gets a z value, or distance value. Whenever a polygon gets translated to a bunch of pixels and gets drawn on the screen, the z value of each pixel is checked against the z value of the pixel already there - if there is any. If the new pixel is closer, it overwrites the old pixel. Otherwise, nothing changes. This z-buffer is then reset before the next frame is drawn.

I assume these games stored a z map for each background, or they simply cut the background up into multiple parts and rendered them closer or further away - which would essentially give different z values anyway. If there's no z-buffer, then the drawing order determines what is shown on top, obviously. :)


Thanks for your reply, but the thing that's confusing me is how you implement a z map. I have Beginning Direct3D Programming and it doesn't say anything about the z buffer except for its function.

Where would I go to learn how to load an image into the Z buffer, or how to get a grayscale image to determine which polygons are drawn or not?

Share this post


Link to post
Share on other sites
While depth-testing probably is used in the Final Fantasy games, it's not the best way to think of the rendering process they use.

Occlusion culling is a method of determining visibility to reduce the geometry needing to be rendered. It is a means of improving performance when objects are likely to obscure one-another.

Depth-testing is a process whereby the projective nature of 3D rendering is removed so that pixels have an associated depth into the screen. This depth is not visible, but it can be used to determine whether a newly-drawn object should overwrite the pixels that already reside on the screen. Depth-testing eases the work for the programmer as it allows them to render geometry in any order, safe in the knowledge that it will come out perspective-correct.

However, both of these methods are primarily used in 3D rendering. They both have applications in the world of 2D but aren't nearly as indispensable as they are in 3D.

The 2nd generation Final Fantasy games use prerendered backgrounds stored as one or more alpha-blended layers. The player is rendered as a 3D model, and, according to the player's perceived depth, will appear behind or in front of the various layers. This effect can be achieved without depth testing and is unrelated to occlusion culling. It's likely that the prerendered layers are actually rendered as billboards in 3D space with depth-testing enabled, but it's important to note that this is a very specific use of depth-testing.

Regards
Admiral

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this