Is it possible to generate terrain semi-procedurally or automatically? Not really sure what the proper terminology is…
Basically, I have a massive heightmap that outlines the general landmass. As opposed to carving out details totally by hand or adding a lot of random noise to it or something, would it be possible to draw out things like mountains and generate them procedurally, and save that data? I read about random generation of essentially infinite terrain at runtime, but is it possible to do it just to aid the development process as opposed to doing it at runtime?
This 3 tutorials cover all procedural terrain generation aspects in Unity:
Ideas in 3D graphics, game development, photo correction, programming , Unity 3D, everyday life, video concepts, social communication etc.
Ideas in 3D graphics, game development, photo correction, programming , Unity 3D, everyday life, video concepts, social communication etc.
Ideas in 3D graphics, game development, photo correction, programming , Unity 3D, everyday life, video concepts, social communication etc.
Additional split terrain script:
Ideas in 3D graphics, game development, photo correction, programming , Unity 3D, everyday life, video concepts, social communication etc.
Automatic grass placement:
https://doctrina-kharkov.blogspot.com/2019/08/unity-automatic-grass-terrain.html
Yes, and this has been done with Unity. Let me try to find the link. There was a video and everything. It was done really nicely.
A quick google search yielded it . And it is indeed called procedurally generated terrain. Head to page 2 and its at the bottom.
Here is another procedural generator .
Kind of late, but if you have terrain toolkit I’ve made a script to generate random textures/heightmaps using terraintoolkit:
using UnityEngine;
using System.Collections;
public class PerlinTerrain : MonoBehaviour {
//Toolkit instance.
[SerializeField]TerrainToolkit kit;
//Array of textures.
[SerializeField]Texture2D sandTexture;
[SerializeField]Texture2D grassTexture;
[SerializeField]Texture2D rockTexture;
[SerializeField]Texture2D cliffTexture;
void Start() {
//Check if we have the kit assigned;.
if (kit == null) {
//If there is not an instance assigned or on gameObject, return.
if (!GetComponent<TerrainToolkit>())
{
return;
}
//Else assign kit to gameObject's toolkit.
else
{
kit = GetComponent<TerrainToolkit>();
}
}
//Generate the terrain.
Generate();
}
void OnGUI(){
if (GUILayout.Button ("Generate")) {
Generate();
}
}
public void Generate() {
//Generate the perlin terrain.
kit.PerlinGenerator((int)Random.Range(3,6),Random.Range(0.4f,0.9f),Random.Range(2,6), 1f);
//Gives it a less smooth feel.
kit.PerlinGenerator(4,4,4, 0.1f);
//Creates arrays for stops.
float[] slopeStops = new float[2];
float[] heightStops = new float[4];
Texture2D[] terrainTextures = new Texture2D[4];
//Assigns values to the arrays.
slopeStops[0] = 30f; slopeStops[1] = 70f;
heightStops[0] = Random.Range(0.05f, 0.18f);
heightStops[1] = Random.Range(0.19f, 0.49f);
heightStops[2] = Random.Range(0.5f, 0.69f);
heightStops[3] = Random.Range(0.7f, 0.89f);
terrainTextures[0] = cliffTexture;
terrainTextures[1] = sandTexture;
terrainTextures[2] = grassTexture;
terrainTextures[3] = rockTexture;
//Paints the textures.
kit.TextureTerrain(slopeStops, heightStops, terrainTextures);
}
public void Generate(bool doublePerlin) {
//Generate the perlin terrain.
kit.PerlinGenerator((int)Random.Range(3,6),Random.Range(0.4f,0.9f),Random.Range(2,6), 1f);
//Gives it a less smooth feel.
if(!doublePerlin){
kit.PerlinGenerator(4,4,4, 0.1f);
}
//Creates arrays for stops.
float[] slopeStops = new float[2];
float[] heightStops = new float[4];
Texture2D[] terrainTextures = new Texture2D[4];
//Assigns values to the arrays.
slopeStops[0] = 30f; slopeStops[1] = 70f;
heightStops[0] = Random.Range(0.05f, 0.18f);
heightStops[1] = Random.Range(0.19f, 0.49f);
heightStops[2] = Random.Range(0.5f, 0.69f);
heightStops[3] = Random.Range(0.7f, 0.89f);
terrainTextures[0] = cliffTexture;
terrainTextures[1] = sandTexture;
terrainTextures[2] = grassTexture;
terrainTextures[3] = rockTexture;
//Paints the textures.
kit.TextureTerrain(slopeStops, heightStops, terrainTextures);
}
}