Closed afonsolage closed 2 years ago
This must address also #19
Some thoughts on this subject:
Currently there is a single pipeline which covers from generating chunks, cache, computing vertices, occlusion, merging faces, [..] until the rendering.
We should split this work and have the following setup:
sector
concept introduced on this issue still relevant? I don't think so
Currently the chunk generation, loading and neighborhood calculation is done on genesis stage of pipeline, but there are other heavy processing tasks, like stated on #7. So in order to solve this, it would be better to move all chunk generation, processing and everything until the final
VertexFace
and cache it.Overview
The idea is to store the processed data in
sectors
. Each one will have 16^3chunk
s (see #10 ) and will be stored in its own file. So there are three flows possible:The general hierarchy will be
world
->sector
->chunk
->voxel
, where:world
controls the loading, unloading and updating ofsector
s;sector
holds and updates allchunk
s all once;chunk
holds allvoxel
s;voxel
a single unit value inside achunk
Only a single
sector
will be updated/processed at a single time, due to it's size.landscape
will query world to get the desired number of chunks as it wants in order to send torendering
pipeline. This will be determined by a draw distance.The load/unload process of sectors should be triggered when player moves at half way of the current sector.
Drawbacks
Memory usage can be pretty high, if each voxel uses 5 bytes (2 bytes for kind, 1 byte for light, 1 byte for faces occlusion and 1 byte for other data), it will consume 516^316^3*9^3 = 2.1 GB. This can be reduced by using compression, since many voxels will be empty or repeated.
When adding propagation, which we currently doesn't have, the game may slowdown if the propagation happens between more than 1 sector, like light or fire spreading, the worst case scenario can be an edge between 8 sectors, which may take a while to process. This is a corner case and shouldn't be a big problem at all
When a player move quickly and triggers the loading and unloading of sectors, moving back and forth, this may slowdown the game, due the high amount of sectors being loaded/unloaded.
Needs to test the loading/unloading of
sectors
on slow HDDs and check how it behaves. Currently I'm using M2 SSD, which is very fast and should not be considered a normal use case.