Need help using VBOs with Frustum Culling

I am currently developing my first 3D game for a school project, the game world is completely inspired by minecraft (a world completely made of cubes). I'm currently trying to improve performance by trying to implement vertex buffer objects, but I'm stuck, I have already implemented the following methods: reject, only draw open faces and reject distances, but I have the following doubts:

  • I currently have about 2 ^ 24 cubes in my world, divided into 1024 pieces of 16 * 16 * 64 cubes, now I am doing an immediate rendering of a mode that works well with the truncation segment, if I implement one VBO per piece, I need to update this vbo every time i move the camera (to update the truncation)? Is there any performance with this?

  • Can I dynamically resize each VBO? Or do I need to make each of the largest sizes (a piece completely filled with objects)?

  • Should I store each loaded fragment in memory or I could effectively delete this VBO and recreate it if necessary.

+4
source share
2 answers
  • Changing the VBO every time you change the camera frustration is hardly a good idea. The overhead of continuous data buffering is likely to outweigh any performance gains you get from drawing fewer polygons. You should probably drop all VBOs when they completely exit the frust. As a result, you will get more policies than necessary, but this will be more than balanced by the fact that drawing from VBO is much faster than drawing in direct mode.
  • You can resize the VBO, but only by making a new call to glBufferData , which can be an expensive call if you send data to a graphics card.
  • You would be better off not storing all the pieces that you created in VBO memory that will quickly get out of hand. Keeping your immediate environment in memory and discarding them when deleted is the best choice.
+1
source
  • The first naive (not necessarily in a bad sense) approach would be to really update the VBO of each frame based on the results of trimming and hiding the face. Keep in mind that using immediate mode does the same (send every vertex to the GPU every frame), but with a million driver calls (don't underestimate glVertex ) instead of several function buffers and one call call.

    Thus, using VBOs (using GL_DYNAMIC_DRAW or even GL_STREAM_DRAW , of course) is likely to be faster than immediate. This is not only a possible GPU storage, but also a reduced number of driver calls that make VBOs (or vertex arrays in general) faster than immediate.

    Later, you can also implement some more complex methods of rejecting equipment using feedback with inverse transformation, so you select directly on the GPU and do not have to send vertex data to the graphics processor of each frame.

  • Since you are updating the entire buffer every frame (and therefore should call glBufferData ), resizing is absolutely not a problem. Just call glBufferData again with a different size.

  • It depends on how many blocks you have. But if their number becomes larger, it may be a good idea to use some caching methods (remove VBO further, select distance, pieces).

+1
source

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


All Articles