OpenGL - selective world rendering

I am building a miniature city with the basic minimal views of the city (roads, buildings, trees, etc.), where you can move around. I know that rendering the entire model installed in each frame does not work ...

So can someone give me an idea of ​​the standard (but simple) procedure used to selectively display only visible parts of the system? I mean, just displaying only visible things (relative to the position of the camera), and not displaying the invisible part. Im using VC ++ and the GLUT API.

+4
source share
2 answers

Perhaps this Wikipedia article provides a very basic introduction to the field of culling techniques.

A good starting point and one of the simplest methods is to discard a truncated cone. Using this method, you check each object in its scene if it is inside the viewing volume (truncation view). This basically comes down to checking some simplified bounding volume of the geometry (for example, a box or a sphere that completely contains the geometry) if it lies inside the viewing truncation defined by six planes.

This can be further optimized by grouping objects by their position and creating a so-called hierarchy of bounding volumes, so you, for example, first check if the entire city block is inside the viewing volume (using the bounding volume that contains the whole block), and only if so, do you also check out individual homes.

A more complex method is rejection of the occlusion, which means checking whether the object is completely hidden behind another object. Since these methods can be significantly complicated, they should (if done) really be executed after the image is rejected. OpenGL has hardware occlusal queries that can help you determine whether the object is actually visible, but this requires additional work. Especially for cities, there may be special two-dimensional methods for rejecting occlusion (I have heard about this for a long time, I do not know).

This is just a very general overview, feel free to google for individual keywords. It is always a good idea to carefully weigh if it requires additional processor costs (especially with complex methods of rejecting occlusion), given that the current trend is to collect as much geometry as possible in a single callback (by the way I hope you do not use the immediate glBegin/glEnd , otherwise it will change to vertex arrays or better VBOs - this is the first item on your agenda). But viewing a breakaway truncation can be a pleasant and easy starting point, especially if the city is becoming quite large.

+3
source

Google "binary spatial partition trees".

BSP trees are a good way to determine what should be displayed from the viewing angle and camera position. High school shooters, i.e. Quake et al. Used them (or at least some inference of principle).

Here is a good FAQ .

Other good resources: link link

0
source

Source: https://habr.com/ru/post/1379349/


All Articles