I don't understand how I would add these together to get a nice outcome like this for example:
Could somebody help out on how to do such a thing? Here is my script:
To create noise you need a float - it's not just a binary black or white, it's a smooth gradient.
As for how to do smooth color gradients, here's a snippet example:
//The two colors to generate noise between var color1 = Color.white; var color2 = Color.red;
var noise = .3; //You'd of course generate this from your perlin function var perlinColor = new Color(color1.r noise + color2.r (1 - noise), color1.g noise + color2.g (1 - noise), color1.b noise + color2.b (1 - noise), color1.a noise + color2.a (1 - noise));
Sorry if that doesn't quite work - I'm a C# programmer guessing at JS.
The procedural examples have a Perlin noise example, available here:
here is a img of unity perlin for reference. it's Mathf.PerlinNoise(x/10, 1.9); dots are x= 1,2,3 etc....
if you do perlin(x/10, 1.1) you'll get a curve like that, 1.1 is the random seed of the curve.
The above function will repeat every 200 or so kilometres, I just found out because I made my terrain with perlin(x/1.0 , 88.2) type of functions, and they all loop exactly the same after roughly 20,000 unity units, which is a surprise if you thought you were making an endless landscape!!! so if you do stuff like
perlin(x*0.789 , 123)*perlin(x*0.987 , 321), then it should repeat every 1 zillion kilometers because they are at different periods :)
NOTE: perlin noise isn't great for total randomisation. in fact it doesn't even go from 0 to 1 as the reference says! if you use it for random, the chances of having 1 and 0 are smaller than the chance of .5 and .8, it seems to be mostly distributed in the centre, probably like a Gaussian curve. To be more evenly distributed, it would have to be zig zag looking not rounded.
I just did a test to count the distribution... it turns out that for lower seeds for example under 20, none of the curve points are higher than 0.9
so! a WEIRD distribution. handy but weird.
the distribution is bottom heavy... esp. with higher seeds. and doesnt go over .9 with small seeds like 1.1
for some purposes you will want to amplify your perlin function and use Mathf.PingPong 0,1,to make it more evenly distributed, and add another perlin to it for granularity.
Also to note: 1.432=seed for perlin is not the same curve as 123.432, it's not modulo'd by 1.
to make more Granularity, to the perlin to make it possible to zoom in to more noise on smaller features... Unity perlin doesnt do that. you would have to add 2-3 perlin graphs together, 1 to make details on the 10/100th dimension, one on the 1/10, and one to make the large waves.