Rendering with Conviction The Graphics of Splinter Cell

Started by
14 comments, last by self_shadow 13 years, 8 months ago
Sorry guys, but I still dont understand the Z-Hiearchy bit. This is how Im thinkin it goes.

- Vertex enters the VertexShader which is enough to hold the contents of an AABB of a single object to be tested
- AABB has 8 points, so calculate all points into NDC space (-1,1)(0,1).
- From these 8 points compute 4 points that are the bounding points of the 8 points in xy. Set each of the 4 points z value to the closest value to the screen of the 4 points z.
- Test these 4 points against the depth buffer.
- if any of them pass the z test, this object could be visible, and return true
Advertisement
If you just test the corners, it won't always work. e.g. imagine look out a window at a wall. The corners of that wall are hidden by the window-frame, but it's center isn't. Just testing the corners here will hide the wall, even though it's visible.

You've got to test every Z-buffer value inside that rectangle, not just a few of them. Seeing these rectangles could potentially cover hundreds (or thousands) or ZBuffer samples, this isn't feasible.
So... the larger an object is, the lower-mip level you use.
If you do this right, you can make it so no matter what size the rectangle, it will always be covering just 4 Z-buffer values (of a particular mip-level).

In the presentation, they say "N" values, but their diagram shows 4 ;)
Ah right, gotcha. But you could always clamp the values. So going back to your wall example, I take it you mean, what would happen if the 4 corners were all outside the view fustum.

But you could solve this by clamping any values outside (-1,1) to (-1,1). This would also require you to calculate the correct Z too, but that wouldn't be too hard.

Also, how do you always only need to test 4 pixels? What if it was something like a long pole?
Quote:Original post by hick18
Ah right, gotcha. But you could always clamp the values. So going back to your wall example, I take it you mean, what would happen if the 4 corners were all outside the view fustum.
No, not the view frustum. The 4 corners aren't representetive of the whole shape. Going back to my 'window' example, the depth buffer might look like below (1 = near, 9 = far, X = corners of the wall on the other side of the window):
[1][1][1][1][1][1][1][1][1][1][1][1][1][X][1][1][1][1][1][1][1][1][X][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][9][9][9][9][9][9][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][X][1][1][1][1][1][1][1][1][X][1][1][1][1][1][1][1][1][1][1][1][1][1]
Let's say the outside wall (the quad make by the X's) is at depth 5. As you can see, the corners of the outside wall are will fail the depth test, but the center of the wall would pass.
Therefore if you only test the corners, you'll get the wrong result.

Quote:Also, how do you always only need to test 4 pixels? What if it was something like a long pole?
The Mip-chain of the above buffer (taking the maximum value of each group of 4 samples) looks like:
        3               2        1      0[1][1][1][1][1][1]  [9][9][9]  [9][9]  [9][1][9][9][9][9][1]  [9][9][9]  [9][9][1][9][9][9][9][1]  [9][9][9][1][9][9][9][9][1][1][9][9][9][9][1][1][1][1][1][1][1]
As shown above, we'd have to test every pixel inside those 4 corners to get the correct result -- the optimisation made by the HZB is to instead test the 4 corners against mip-level 1 (above). If the 4 corners were closer together, you'd use mip level 2 or 3, or even the original high-res depth buffer if the corners were close enough together.

A long diagonal pole is kind of worst-case for this algorithm, because it's screen-space bounding box is going to cover a large screen area, even if the pole itself doesn't. For those kinds of objects, you might be better off giving them several smaller AABBs instead of one big one.
Thanks for clearing that up :)
Quote:Original post by hick18
Yeah, its rather annoying. They dont seem to mention where the test is done.

Sorry for the confusion. The Gamefest slides online are also an older version than the ones I presented with, without any of the notes! (For anyone who finds this thread later, definitely check out the GDC ones, linked to from RTR blog post.)

EDIT: I was wrong about this; they are the version I presented, but the GDC notes are a bit more detailed. I'll work on updating them.

It looks as though you all pieced things together anyway (Hodgman and venzon's posts in particular), but if you have any more questions, feel free to email me (address at the end of the slides).

As for blogging, Nick Darnell beat me to it: http://www.nickdarnell.com/?tag=hierarchical-z-buffer

[Edited by - self_shadow on August 24, 2010 11:49:47 AM]

This topic is closed to new replies.

Advertisement