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,66 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
|
||||
public abstract class TextureGenerator : ScriptableObject {
|
||||
public enum TextureSize { u128 = 128, u256 = 256, u512 = 512, u1024 = 1024, u2048 = 2048, u4096 = 4096 }
|
||||
|
||||
[Header ("Texture Settings")]
|
||||
public string textureName = "Unnamed";
|
||||
public TextureSize textureSize = TextureSize.u512;
|
||||
public FilterMode filterMode = FilterMode.Bilinear;
|
||||
public GraphicsFormat format = GraphicsFormat.R8G8B8A8_UNorm;
|
||||
public bool useMips = true;
|
||||
|
||||
[Header ("Compute Settings")]
|
||||
public ComputeShader compute;
|
||||
public int seed;
|
||||
public Vector4 testParams;
|
||||
|
||||
[SerializeField, HideInInspector]
|
||||
protected RenderTexture renderTexture;
|
||||
|
||||
public RenderTexture GenerateTexture () {
|
||||
int resolution = (int) textureSize;
|
||||
CreateTexture (ref renderTexture, resolution, textureName);
|
||||
|
||||
if (compute) {
|
||||
compute.SetVector ("params", testParams);
|
||||
Run ();
|
||||
|
||||
if (useMips) {
|
||||
renderTexture.GenerateMips ();
|
||||
}
|
||||
}
|
||||
|
||||
return renderTexture;
|
||||
}
|
||||
|
||||
protected abstract void Run ();
|
||||
|
||||
void CreateTexture (ref RenderTexture texture, int resolution, string name) {
|
||||
if (texture == null || !texture.IsCreated () || texture.width != resolution || texture.height != resolution || texture.useMipMap != useMips || texture.graphicsFormat != format) {
|
||||
if (texture != null) {
|
||||
texture.Release ();
|
||||
}
|
||||
texture = new RenderTexture (resolution, resolution, 0);
|
||||
texture.graphicsFormat = format;
|
||||
texture.enableRandomWrite = true;
|
||||
|
||||
texture.autoGenerateMips = false;
|
||||
texture.useMipMap = useMips;
|
||||
texture.Create ();
|
||||
}
|
||||
texture.wrapMode = TextureWrapMode.Repeat;
|
||||
texture.filterMode = filterMode;
|
||||
texture.name = name;
|
||||
}
|
||||
|
||||
void OnDestroy () {
|
||||
if (renderTexture != null) {
|
||||
renderTexture.Release ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue