background:
This is the 3D Engine dev. Series Tutorial of Delphi 3D. (Www.delphi3d.net)
This Site is written and maintained by tom nuydens.
From the basic view system to advanced PVS (Possible Visible Set), it has an introduction. It is difficult to write deep shallow, don't think Tom Nuydens is a legendary figure, he is 22 years old, and he has just graduated from University. I really don't roll rolling!
My translation:
I have recently seen Computer Graphics, I found this station, I found it is useful, so I am translated by Learning by Doing && Share && Just For Fun (Welcome to Id), and add some of my understanding and some Expand (Maths, Some New Figures etc.).
[
statement
]
: This article is taken
Www.delphi3d.net
Website
3D Engine dev.
The column, its copyright belongs to the original person. Translator
Translate this article without the agreement of the original person. This translation is only for self-study and reference, please read this article, do not reprint, spread this translation; people download this translation content, please remove its backup immediately after reading. Translator
People who violate the above two principles are not responsible. This declaration.
============================================================================================================================================================================================================= ======================
Portal Rendering
The previous section describes the Visibility Determination algorithm. This time I discussed the Portal Rendering Algorithm.
1. The first step of the Basic Portal Rendering algorithm to perform Portal Rendering is to divide your space into a convex space, which is connected to each other by Portal. When drawing, starting from the child space where the observer is located, if there is portal in these subasses, it will first deal with the subastroves behind Portal. When drawing another child space from a sub-space, Portal will be used for cutting of other portals. The following few pictures can make it easier to understand the above algorithms:
The black contour is your house. The blue line segment is portals. The portals were compiled in the first picture. The red dot indicates the observer, and the arrow refers to the direction of sight. The green line indicates the field of view. The first step is now, the observer faces a wall, and the left side can see No. 1 Portal, then take the child space behind Portal. Thus, adjust the field of view, and the polygons that cannot be seen through Portal 1 are deleted. In the adjusted field of view, Portal 2, Portal 3 is visible. If Portal 3 is processed first, because Portal 3 does not have another portal, the subaspace can be drawn. Then, continue to process Portal 2, and simply simply draw the subastrips behind Portal 2. Handling all portals after portal 1, returns to the child space where the observer is at the beginning, the space has only one portal ----- Portal 1, so that the space is drawn.
The above example is just to explain the basic algorithm, not a good example of the superiority, because all the subcompens: (. Now see an example of a sub-space that needs to be drawn:
Walking over the algorithm, you will find that most of the subspace will not draw anyway. (NOTE: Tailor and Field Of VIEW,
Or tailoring between portals, will further reduce the number of subaspaces that need to be drawn. )
2. Sector Subdivision (sub-space division) Portal Rendering is the most important question ---- you should put the portals there. "Subspace is a convex subsector" this requirement to produce too much portals. So, you need a way to automatically place portals. If you can't do it, you need to consider the concave space: (. Why do we need a boss space? Because the boss space can be sorted without polygonal shapes, Just draw a polygon, one will not cover another. With the yolk space, it will reduce the portals. (If you want to put a bump 20 in the next room, you can experience two types of subspace belts. The difference is different.)
In UnTITLED-3D (3D Engine) of Tom Nuydens, I will use a concave space. Of course, if you use a concave space and a transparent surface (refer to portal), you must avoid the polygon sorting ---- You have to know the polygon from the back forward. This is why each sub-space in Untitled-3D needs to build a BSP tree. This sounds quite complex, but in this way, the number of portal can be reduced to the extent that can be accomplished with "handmade". If you have to use the portal to place portal, you have a lot of choices. It is commonly used to use a leaf-BSP (a polygon in the leaf node instead of the intermediate node, the Node-BSP relative to the Node-BSP), and the polygon in the leaf node is formed into a convex space.
If you are interested, you can refer to
Harmless' Colum at www.flipcode.com, also has some useful articles in GameProg.com.
3.PLOYGON SORTING (polygon sort)
If the concave space is used, the polygon sorting is less. The above has been mentioned that the Untitled 3D uses the BSP tree to represent each sub-space. However, when you want to handle the moving object, you have a lot of gods: This type of object is not included in the BSP - because if so, you need to build a BSP tree in real time, the complex space BSP tree build is an extremely time. (Several hours: (.....). Usually the polygonal sort of sports objects, use simple z-buffer. But still have to beware, steps are as follows: - Traverse the BSP tree, drawing opaque polygons.
- Draw moving objects.
- Mark Z-buffer is read-only (with gldephtmask ())
- Traverse the BSP tree again, just draw transparency
-Re-enable z-buffer
In this way, everything is OK. is it? Another point: Your moving object cannot be transparent. This is usually not a problem -, for example, if you want to express shooting effect with the sprite (imagine Plasma Gun shooting, the beautiful blue light, but according to my observation of the Plasma gun in Quake, it seems that it is not used. Elf: (, just it is it :))), a wizy will not bring trouble.
4. Conclusion (small knot)
The basic Portal Renderign algorithm is far from the practicality and needs to be improved.
With a concave space can solve too many problems with Portals, you don't need to dig empty thoughts to find a reasonable way to place portals. But at the same time, the problem of polygon sorting, I also discussed some ways to sort.
Next Time, Part 3 Data Structures for 3D Engine.