Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Create only one vertex buffer for each chunk #61

Closed
LukasKalbertodt opened this issue Jul 23, 2016 · 3 comments
Closed

Create only one vertex buffer for each chunk #61

LukasKalbertodt opened this issue Jul 23, 2016 · 3 comments

Comments

@LukasKalbertodt
Copy link
Member

Doing a draw call for every hex-pillar-section is very inefficient. The goal is to manage only one big vertex (+ index) buffer for each chunk. Then we just have to do one draw call per chunk, which results in less then 100 draw calls for the whole world. With that, the draw call amount is not the bottleneck anymore.

Only having one big buffer also allows us to simplify the mesh and remove redundant points and empty faces. Furthermore we can introduces terrain smoothing if we want to.

Some quick calculation for the worst case (no two adjacent hex pillars have the same height) with only one section per pillar:

We have CHUNK_SIZE² pillars per chunk (currently 16² = 256). We have 2 * 6 points for each pillar, but need to triple those in order to have correct normals (see #60) => 36 vertices per pillar = 9216 vertices per chunk. This could be decreased a lot by terrain smoothing.

All top faces are drawn with 4 triangles (with terrain smoothing it would be 6), double that to get the bottom faces, too.
Each pillar has 6 side faces which are drawn with 2 triangles each. But luckily every side face is shared by two pillars, so we can remove roughly half of those faces. This results in 256*6/2 = 768 side faces = 1536 triangles for the sides.

In sum: 1024 + 1536 = 2560 triangles and 9216 vertices per chunk.

These numbers seems OK to me... It's of course also worth considering not generating vertices and faces at height 0, because the player will never see them anyway.

@LukasKalbertodt
Copy link
Member Author

We will use instancing now to improve rendering performance. This is only needed for #62.

@LukasKalbertodt LukasKalbertodt removed this from the Second Week milestone Jul 25, 2016
@jonas-schievink
Copy link
Contributor

Lowering priority to low since we decided to postpone #62 and instancing is doing its job fine (plant rendering is now the main rendering bottleneck)

@LukasKalbertodt LukasKalbertodt self-assigned this Aug 2, 2016
@jonas-schievink
Copy link
Contributor

Done in #190

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants