Here it is: routine for realtime changes of RidgeNoise parameters. Though, still no luck with terrain tweaking: i would like to have plain territory with sevaral mountains. If anybody has settings for it - you’re wellcome to share. I guess, i should scale its ox-oy axis’s
Now i got something like this:
using UnityEngine;
using CoherentNoise;
using CoherentNoise.Generation;
using CoherentNoise.Generation.Displacement;
using CoherentNoise.Generation.Fractal;
using CoherentNoise.Generation.Modification;
using CoherentNoise.Generation.Patterns;
using CoherentNoise.Texturing;
public class NoiseTest : MonoBehaviour
{
private ParticleSystem.Particle[] points;
private int count = 0;
float _freq = 1;
float _lac = 1.2f;
float _oct = 4;
float _exp = 1;
float _off = 1;
float _gain = 2;
float _mul = 0.6f;
// Use this for initialization
private void Awake()
{
Debug.Log("Starting particles");
points = new ParticleSystem.Particle[64*64];
Rebuild();
}
private void Rebuild()
{
var desert = //new Gain(
// new ValueNoise2D(23456) * 0.6f, 0.1f);
new RidgeNoise(23478568)
{
Frequency = _freq, // 1
Lacunarity = _lac, // 2.17
OctaveCount = (int)_oct, // 4
Exponent = _exp, // 1
Offset = _off, // 1
Gain = _gain // 2
} * _mul ; //, 0.3f);
var terrainGenerator = desert.ScaleShift(0.5f, 0.5f);
count = 0;
for (int x = -31; x < 32; x++)
{
for (int y = -31; y < 32; y++)
{
int z = 0;
float groundHeight = terrainGenerator.GetValue(x, y, 0);
points[count].position = new Vector3(x, groundHeight, y);
points[count].color = new Color(0f, 0f, 0f);
points[count].size = 1f;
count++;
}
}
}
void OnGUI ()
{
GUI.Label(new Rect(10,0,150,50), "Freq : " + _freq);
_freq = GUI.HorizontalScrollbar(new Rect(120, 0, 100, 20), _freq, 0.1f, 0.0f, 5.0f);
GUI.Label(new Rect(10,40,150,50), "Lac : " + _lac);
_lac = GUI.HorizontalScrollbar(new Rect(120, 40, 100, 20), _lac, 0.1f, 0.0f, 5.0f);
GUI.Label(new Rect(10,80,150,50), "Oct (int) : " + _oct);
_oct = GUI.HorizontalScrollbar(new Rect(120, 80, 100, 20), _oct, 0.1f, 2.0f, 12.0f);
GUI.Label(new Rect(10,140,150,50), "Exp : " + _exp);
_exp = GUI.HorizontalScrollbar(new Rect(120, 140, 100, 20), _exp, 0.1f, 0.0f, 5.0f);
GUI.Label(new Rect(10,180,150,50), "Offset : " + _off);
_off = GUI.HorizontalScrollbar(new Rect(120, 180, 100, 20), _off, 0.1f, 0.0f, 5.0f);
GUI.Label(new Rect(10,220,150,50), "Gain : " + _gain);
_gain = GUI.HorizontalScrollbar(new Rect(120, 220, 100, 20), _gain, 0.1f, 0.0f, 5.0f);
GUI.Label(new Rect(10,260,150,50), "Multiplier : " + _mul);
_mul = GUI.HorizontalScrollbar(new Rect(120, 260, 100, 20), _mul, 0.1f, 0.0f, 5.0f);
if (GUI.Button(new Rect(50, 300, 100, 50), "Rebuild"))
Rebuild();
}
private void Update()
{
particleSystem.SetParticles(points, points.Length);
}
}