Infinite Generator
Note
This feature is only available in Tessera Pro
Tessera's generator only builds finite levels. This utility can be used to lazily generate infinite levels by repeatedly applying the generator.
It works by splitting up the space into an grid of chunks. Then it works out which chunks need to be generated, and fills each one with the output of the configured generator.
Configuration
generator
- sets the generator that is used to fill the chunks. It also determines the size of each chunk.
parallelism
- the number of chunks that can be generated concurrently. Note that turning this up can cause slightly worse quality output.
watchedColliders
- determines the volume in which chunks should be generated. You typically want to use a large trigger collider following the player or camera, to ensure that everything nearby is generated.
infiniteX
- You can set each of X, Y and Z to repeat infinitely. If this is false, you can specify the min/max chunk to give a limit to the amount of chunks generated.
Chunk Cleanup
By default, chunks are never removed. This can cause memory usage to grow unboundedly as your game runs. You can enable chunk cleanup to resolve this. The generator will periodically scan for chunks that haven't been near a watched collider recently, and clean them up according to ChunkCleanupType:
- None - Chunks are never removed.
- Memoize - Remove the GameObjects, but keep tile data so they can be recreated exactly
- Full - Remove everything associated with the chunk.
Memoize is usually desirable if players can return to a chunk later, otherwise Full is more memory efficient.
In either case, you can set chunkPersistTime to control how long chunks stick around for when not needed, and cleanupInterval to control how frequently to scan for chunks.
Caveats
- Only works for square and cube grids
- Only works at runtime
- Generator constraints may not behave intuitively as they only operate on each chunk.
- Scene based constraints are ignored (as scanning for them quickly becomes extremely expensive as the level gets too large).
- Even with a fixed seed, this generation is non-deterministic, as it depends on the order of chunk evaluation.