Skip to content

Improve World Generator

Choose a tag to compare

@stephen-hqxu stephen-hqxu released this 02 Dec 12:07
df58404

Release 0.15.8

Heightfield generator

To disambiguate and for clarity, we renamed a few free-slip related stuff to nearest neighbour. This decision is made because free-slip is a concept used in hydraulic erosion, but it is overused in the codebase. Things like biome smoothing and splatmap generation which take also neighbour chunks around the centre chunk during generation should not be referred as and confused with free-slip generation.

Therefore, the following files (and corresponded class) are renamed:

  • STPFreeSlipTextureBuffer -> STPNearestNeighbourTextureBuffer
  • STPFreeSlipInformation -> STPNearestNeighbourInformation
  • STPTestFreeSlip -> STPTestNearestNeighbour

A quick summary of the major changes:

  • In STPChunkSetting, split NN setting for diversity generation and erosion. We also renamed a few settings and improve documentation for clarity.
  • Rewrite and re-document STPNearestNeighbourTextureBuffer. Now memory mode is part of the template parameter.
  • Split generation procedure in STPHeightfieldGenerator into 2 separate functions, heightfield generation and erosion. Also eliminate dynamic memory allocation by passing terrain maps as raw pointers.
  • STPHeightfieldGenerator no longer calls cudaSetDevice(), it gives user more freedom to choose their device context if they are working with a multi-GPU system (for example rendering on GPU 0 and computing on GPU 1).
  • It is now application's responsibility to ensure the number of nearest neighbour chunk is the same as the value passed during initialisation of the NN texture buffer and generator.
  • Rewrite test for STPNearestNeighbourTextureBuffer.

There are way too many changes involving heightfield generators to summarise them briefly, I have rewritten the documentation in code so take a look to find out more.

STPWorldPipeline

We have moved the terrain generation from real-time streaming, i.e., send chunk to renderer as soon as one is done, to the way that returns only when all chunks in a render distance are available. This is done because STPWorldPipeline already has a double buffer system that is swapped only when all generations are done, so it is no longer necessary to stream chunks immediately to back buffer.

Generator manager in STPWorldPipeline has been revised with added implementation for efficient neighbour condition checking and scheduling to avoid race condition.

STPChunk

  • Change the function calcChunkNeighbour to calcChunkNeighbourOffset. The difference is the prior one returns chunk world coordinate and the latter one returns relative offset, which can be converted to world coordinate by adding the coordinate of the centre chunk. This can help the world pipeline to cache neighbour offsets and reuse to avoid repetitive small memory allocation.
  • Remove all internal states tracking such as occupancy status, it only holds texture data and completion status.
  • Fix an incorrect calculation in calcLocalChunkCoordinate().
  • Add a new function calcLocalChunkOrigin().
  • Refactor some class like STPNearestNeighbourTextureBuffer and heightfield renderer to make use of the chunk utility functions instead of calculating from scratch.
  • Improve testing robustness for chunk calculations in STPTest2DChunk.

General fixes and improvement

  • Remove the constructor overload for taking C-style array in STPProgramManager.
  • Qualify all function arguments as const whenever sensible.
  • Add inline to all separate template definitions to ensure ODR.
  • Fix an erroneous surface 3D write addressing in STPRandomTextureGenerator kernel, surface meant to be addressed using byte rather than index.