jaredyork / TutorialInfiniteTerrain

The full code for my infinite procedurally generated terrain tutorial for Phaser 3.
MIT License
22 stars 9 forks source link

Chunk.unload() hurts performance #1

Open Teelord opened 5 years ago

Teelord commented 5 years ago

Hi Jared,

Thanks for sharing this code. It's very informative and easy to follow.

I noticed that whenever a Chunk is unloaded, the rendering hangs. I was wondering if you had looked into this or had any ideas how to optimize that part. Whenever you reach the edge of a chunk, you'll see a pause in movement as Phaser clears out the Group.

I've tried small tweaks, deferring unloading until the scrolling has stopped, etc. to make it less noticeable but it seems like unloading a whole chunk is costly and interferes with rendering no matter what I do.

Thanks!

T

Teelord commented 5 years ago

Hi again. I've tried shrinking chunk size to 8 and it seems to spread out the processing load of clearing the group... Is this a reasonable solution? Does making chunks that are so small (i.e. 1/4 the original size) defeat the benefit of using chunks?

One non-performance issue that I noticed is that since the water sprite tile animations aren't synchronized, it allows you to see the edges between chunks (I haven't yet tried fixing this). Smaller chunks makes this more obvious.

Thanks again.