Texture Asset
To texture the ground you will have to create first a texture Asset. That is a holder for the texture and basic settings. What would be expected of a material for now it’s there. There are still some missing settings that will be implemented later on.
Let’s generate a texture asset through “Assets/Create/Infinite Lands/Assets/Texture”, name it “Ground” and open it.
And let’s go over the fields.
- Albedo, Height Map, Normal Map and Occlusion Map correspond to the textures of the same name.
- Size: Size of the texture when sampled
- Normal Strength: Strength of the normal map
This new object and more can be added to the Texture Array on the Biome GameObject to draw procedurally the terrain.
Vegetation Asset
The Vegetation Asset will define the mesh, material and configuration of that vegetation. It can be reused to spawn the same vegetation between biomes.
There are two types of vegetation:
- GPU Instancing: Recommended way to spawn vegetation. It will use GPU Instancing to spawn all the meshes without creating a gameobject.
- CPU Instancing: If instead you want default gameobjects, you can use CPU Instancing so that Unity Spawns each of the instances themselves.
Let’s go over the fields to understand them.
Configuration:
- Distance Between Items: Distance between each item to be spawned.
- Minimum Scale and Maximum Scale: Min and Max size of the asset. Value 1 will draw it in the same size of the mesh, while a range of values allows for randomness between items.
- Vertical Position: In case the objects need to be vertically adjusted, this value can be set to adjust the models and colliders accordingly.
- Align to Ground: In case the object needs to be aligned with the ground. This value can be set to Up, Terrain and Ground
Main Data:
- Cast Shadows (Should it cast a shadow?): It will add a new lighting pass to cast shadows into the ground. It duplicates the number of batches per vegetation so enable it on objects that make sense to cast (not recommended for high-density objects).
- Generate Colliders (Should it add colliders?): Generates the provided collider around the player (not recommended for high-density objects)
- Cross Fade Dithering (Should it smoothly transition between LODs?): Enables crossfade dithering, which will allow smooth transitions between LODs plus disappearing when close to the camera.
Generation:
- LOD Groups: In case one is provided, materials and meshes will be automatically fetched from the prefab.
- LOD: In case no LOD Group is provided, you will have to set up the mesh and the material for each manually.
Rendering:
- View Distance: Units until objects are no longer rendered
- High Lod Distance: Distance to stop loading the highest LOD setup. Each LOD will be swapped logarithmically independently of the View Distance.
- Shadows Distance: Distance to stop casting shadows. Independent of View Distance, but dependent on shadow distance in render settings of your unity project (if the render settings shadow distance is smaller, it will not render further than that)
- Collision Distance: Distance from the player to load colliders around.
Debugging
- Draw Distances: Visualize the distance of each quad tree to enable and disable the corresponding chunks
- Draw Bounding Boxes: Visualize the bounding box of the vegetation chunk. Used for quick frustum culling.