K
K
Kiril12212020-04-16 10:14:46
3D
Kiril1221, 2020-04-16 10:14:46

What is the point of Z-buffering, how do I imagine that he will not draw a scene with a couple of thousand polygons in 10 years?

I read about the z-buffer, and these examples with 2 cubes, or 4 lines, immediately the question is, what if there is, well, the most common game scene from Skyrim or any other game of the 21st century, there are also several million faces, that is, 100 trees standing one after another, and that 99 trees will be outlined, and then 100 will be covered
. Either I don’t understand something, or it hasn’t been used for 30 years.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Pankov, 2020-04-16
@Kiril1221

Z-buffering is needed to correctly intersect objects of complex shape.
In modern graphics, everything is more complicated, but z-buffering will never go anywhere. It's just another trick to achieve some specific goals.
In general, drawing 2k polygons is a trifling task for modern video cards. It is important that trees or some other objects behind look through the holes in the foliage of this hundredth tree of yours.
The polygons are sorted by the distance to the camera. First, the most distant ones are drawn, then those that are closer.
Z-buffer, by the way, is used not only to determine the overlap of objects, but also to quickly find objects under the beam.

A
Alexander Skusnov, 2020-04-16
@AlexSku

Usually, billboard technology is used for wood, i.e. a flat rectangle that rotates to face the camera. Those. 100 trees - 100 squares, 200 triangles, draw - just spit (there may not be very many textures themselves, but each tree can be changed in size and color).
Z-buffer is needed if you are too lazy to sort objects by distance from the camera. Sometimes this cannot be done at all for intersecting solids.

A
Alexander Pavlyuk, 2020-04-16
@pav5000

All modern games use z-buffer. Including all sorts of GTA V.
And if you draw nearby objects first, then the rendering of fragments blocked by the z-buffer will be cut off by the video card in hardware, and this is very fast. Most of the time they won't be rendered completely.
Plus, there will never be a situation with 99 full-poly trees on one line in the game, because other technologies are used besides the z-buffer.
For example, thanks to LOD, only the nearest objects will have the full number of polygons, and the further the object is, the more low-poly its version will be substituted for it. Instead of the most distant objects, there will generally be flat pictures.
Thanks to visibility trees, some of the objects that should not be visible to the camera will be removed from the frame, they simply will not be drawn, because the engine will understand that they are blocked from view.
etc...
There are ways to do without the z-buffer in some places. For example, for rooms, binary trees are used to draw walls in order from closest to furthest.
Plus, for objects with transparency, the z-buffer cannot be used at all, you have to sort the faces and draw them in order from farthest to nearest so that the transparency is correctly superimposed.
In short, the nuances of a wagon and a small cart.
I advise you to read a series of posts on Habré "how a frame is rendered in game n" https://habr.com/en/company/ua-hosting/blog/271931/it shows all the steps pretty well, including the z-buffer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question