ProceduralPlanets

◆ MeshLODSubdivisions

int [] ProceduralPlanets.PlanetManager.MeshLODSubdivisions
staticgetset

Array of Level of Detail (LOD) subdivisions levels. Valid values in array: 0 - 6.


The first entry in array is highest level of detail, last entry in array is lowest level of detail.

Subdivision levels:
0 = 8 triangles
1 = 32 triangles
2 = 128 triangles
3 = 512 triangles
4 = 2048 triangles
5 = 8192 triangles
6 = 32768 triangles

Default array is 6,5,4,3,2 (32768 (highest LOD), 8192, 2048, 512, 128 (lowest LOD) triangles)

Important: Size of array must be same as MeshLODSteps is set to.

When changed, the LOD meshes are automatically recreated with the new number of subdivisions.



using System.Collections;
// This example requires a PlanetManager instance to be present in the scene.
// Add the "Procedural Planets/Prefabs/PlanetManager" prefab to the scene first.
// Then create another gameobject and attach this example script to it.
public class Example : MonoBehaviour
{
void Start()
{
// Create a random planet at the center of the scene
PlanetManager.CreatePlanet(Vector3.zero);
// Set the Mesh Detail Mode to Level of Detail (LOD)
PlanetManager.MeshDetailMode = PlanetManager.MeshDetailModes.LOD;
// Set number of LOD levels to 5
PlanetManager.MeshLODSteps = 5;
// Set the mesh detail levels by using an array of subdivision levels
// The first value in the array is the highest level of detail and the last value in the array is the lowest quality
PlanetManager.MeshLODSubdivisions = new int[5] { 6, 5, 4, 3, 2 };
// Set the planet sizes used to transition between mesh LOD levels
// Note: There are only 4 entries in this array because it specifies the size *between* the LOD levels.
// The float values in the array represent the ratio between screen height and the height of a planet as seen by the camera.
// E.g. the value 0.5f = when the planet takes up half the screen height.
PlanetManager.MeshLODPlanetSizes = new float[4] { 0.6f, 0.4f, 0.2f, 0.05f };
}
}
See also
MeshDetailMode, MeshLODSteps, MeshLODPlanetSizes