ProceduralPlanets

◆ MeshLODPlanetSizes

float [] ProceduralPlanets.PlanetManager.MeshLODPlanetSizes
staticgetset

Array of Level of Detail (LOD) planet size levels. Valid values in array = 0.0f and up The first entry in array is highest level of detail, last entry in array is lowest level of detail.

The sizes are specified from 0.0f (0%) - 1.0f (100%) but can also be higher than 1.0 (e.g. 1.5 = 150%) The size of the planet is calculated by comparing the planet diameter as seen by a specified camera (main camera by default) and comparing it to the height of screen.

Default array is { 0.8f, 0.3f, 0.1f, 0.05f }

Important: Size of array must be MeshLODSteps - 1

The reason it's - 1 is because the sizes specifies between each step and if there are 5 steps there are only 4 transitions between the 5 steps, e.g.: (Step0) Size0 (Step1) Size1 (Step2) Size2 (Step3) Size3 (Step4)



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, MeshLODSubdivisions