Scatter System Overview - Gameslinx/Tessellation GitHub Wiki
Scatter System
The scatter system is the name given to the technique of placing vast quantities of objects across planet surfaces. This page will give you an overview of the underlying theory on how it works. The other pages will discuss the config creation.
How it works
This is a 'quad'. On every planet, the terrain is divided up into these quads. Each are 15x15 vertices which results in 392 triangles in total.
Using a compute shader, each triangle is processed in parallel. A population multiplier determines how many times each triangle is processed. Then, for each triangle, a number of points based on the population multiplier are evaluated. A spawn chance is determined from a number of factors such as altitude, slope, or procedural noise values. If the spawn chance is great enough an object will be placed at this position.
The amount of quads on a planet is determined by the planet's 'maxLevel'. This tells KSP's procedural quad sphere (PQS) responsible for the terrain how many times a quad should be subdivided. A maxLevel of 10 will result in a high level of detail, whereas a maxLevel of 3 will not. This also depends on planet size. Larger planets require larger maxLevels to achieve the same level of detail as a smaller planet with a lower maxLevel.
Distribution
These are two quads with procedural noise generated for each vertex.
Using procedural noise, the distribution of objects can be made less uniform. Where there are dark spots, objects will not generate. The threshold at which this occurs can be adjusted.
There are three possible noise types - Perlin, Ridged Multifractal and Billow. Each have different characteristics, but Billow has been omitted from this wiki because it's very similar to perlin at this scale.
Scatter Types
There are four different types of scatters:
- Persistent
- Non-Persistent
- Volume
- Fixed-Altitude
Persistent Scatters
These scatters generate using the rules defined above, will stick to the surface, and will remain in the exact same location. Typically, this is the method used to place rocks or trees.
Pros:
- Persistent
- Suitable for collisions
- Low memory impact
Cons:
- Procedural noise quality limited by maxLevel. Can't achieve fine detail - better for large distribution variation
Non-Persistent Scatters
Typically used to place vast amounts of scatters in a small area, such as grass. These are not persistent and will result in defaulting to the initial placement when reloading, restarting the game or regenerating the scatters.
Pros:
- Very good detail
- Good for frequently occurring scatters
Cons:
- Not persistent
- Medium memory impact
- Not collideable
Volume Scatters
Volume scatters can also generate objects upwards. A typical use for this would be kelp. Kelp has long tendrils with a similar structure stacked on top of itself. Volume scatters can stack objects on top of others up to a certain altitude, such as the ocean surface, regardless of the initial altitude of the terrain. This makes kelp forests possible without the kelp growing out of the sea. That would be a bit odd.
Pros:
- Enables the generation of interesting, contextual objects
- Allows off-the-surface placement
- Persistent
- Collideable
Cons:
- Largest memory impact
Fixed-Altitude Scatters
Follows exactly the same rules as persistent scatters, but instead places scatters at a specific, defined altitude. A typical use case would be ice bergs that float on top of the ocean. These scatters can be constrained by the same rules as persistent scatters, such as min/max altitude. This means that you can define a terrain altitude range at which these objects will generate at before they are repositioned to the defined altitude. Ice bergs, for example, are more common in shallower water because the temperature is cooler nearer the coast due to the less water there. This makes that distribution possible.
Pros/Cons are the exact same as persistent scatters.