1
\$\begingroup\$

I am creating a voxel world, (like any other person), but I currently have a small performance hit when loading/unloading chunks.

Right now I can load and unload chunks dynamically with "infinite" type world. I am using VBO's to store chunk data with float buffers. Also, (my big point), I am using Greedy meshing to only render the edges I need. My only thought of why it's not loading well is that I am using SSAO shading, which should have a hit on my FPS, but my FPS stays in the high 200's. Also, I am using frustum culling and normal culling. What I want is the player to have a really large render distance without actually rendering the chunks until the player is close. Almost like fog but instead of covering up unloading, it's actually reducing the detail as you move away.

Also, when a player creates a voxel or destroys a voxel (basically any change in the chunk) it saves the chunk to a file in the corresponding world folder.

Any ideas?

Here is a video of the game in its' current stage.

Here's a screenshot with a far render distance. Anything with a render distance that is far, hits the performance BADscreenshot

\$\endgroup\$
1
\$\begingroup\$

I can see two problems with what you're describing;

Saving to a file on voxel change is unnecessary, you only need to save a chunk when it's unloaded (or the user requests a save).

I strongly suspect you are loading/unloading on the main thread, this is going to cause stuttering; you need to do this off the main thread (and so allow it to go over multiple ticks if needs be)

So the program should initiate loads at a point in it's cycle then "check back later" to see if the load has finished, if it hasn't that's fine it'll catch it later, once the load has finished the chunk gets attached to the main world

\$\endgroup\$
0
\$\begingroup\$

Alright, I did what needed to be done. There is a greater number of people on this stackexchange that need help then actually help. Here's what helped me:

  1. Make sure you aren't using "new" in your main loop, use ObjectPools, garbage collectors can kill games unexpectedly.
  2. Increasing draw distance greatly increases drawcalls. You need a LOD system to group far away chunks to the same VOB
  3. Measure how many drawcalls, texture and shader switches you have and try to find some relation between that and fps. If that doesn't help, try GPU/CPU profilers, to find out where the bottleneck is.
\$\endgroup\$
  • \$\begingroup\$ You can also accept your own answer if you like to, just click the tick below the voting buttons. Also: You asked your question on a weekend that is also a holiday in catholic parts of the world. So you might have had bad timing. \$\endgroup\$ – dot_Sp0T Jun 5 '17 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.