Procedural Planets
Integrated Sebastian Lague's Planet Generator Created Tour function in SectorRenderer which makes the camera follow each terrestrial planet in turn
This commit is contained in:
parent
f8165878e0
commit
53a91351b7
332 changed files with 11904 additions and 78 deletions
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class CelestialBodyShape : ScriptableObject {
|
||||
|
||||
public bool randomize;
|
||||
public int seed;
|
||||
public ComputeShader heightMapCompute;
|
||||
|
||||
public bool perturbVertices;
|
||||
public ComputeShader perturbCompute;
|
||||
[Range (0, 1)]
|
||||
public float perturbStrength = 0.7f;
|
||||
|
||||
public event System.Action OnSettingChanged;
|
||||
|
||||
ComputeBuffer heightBuffer;
|
||||
|
||||
public virtual float[] CalculateHeights (ComputeBuffer vertexBuffer) {
|
||||
//Debug.Log (System.Environment.StackTrace);
|
||||
// Set data
|
||||
SetShapeData ();
|
||||
heightMapCompute.SetInt ("numVertices", vertexBuffer.count);
|
||||
heightMapCompute.SetBuffer (0, "vertices", vertexBuffer);
|
||||
ComputeHelper.CreateAndSetBuffer<float> (ref heightBuffer, vertexBuffer.count, heightMapCompute, "heights");
|
||||
|
||||
// Run
|
||||
ComputeHelper.Run (heightMapCompute, vertexBuffer.count);
|
||||
|
||||
// Get heights
|
||||
var heights = new float[vertexBuffer.count];
|
||||
heightBuffer.GetData (heights);
|
||||
return heights;
|
||||
}
|
||||
|
||||
public virtual void ReleaseBuffers () {
|
||||
ComputeHelper.Release (heightBuffer);
|
||||
}
|
||||
|
||||
protected virtual void SetShapeData () {
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnValidate () {
|
||||
if (OnSettingChanged != null) {
|
||||
OnSettingChanged ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue