Well I only know what I read about it and it isn't really something you learn in a school.

Basically the plugin allows you to make perlin or simplex noise (look them up to see what they look like). The plugin uses a "seed" for the randomness so with the same seed noisejs.perlin2(0.5, 0.1) for instance will always give the same value, whereas c2's random() will give a different value every time.

Now from what I've read and messing with the plugin this is some info about the expressions.

noisejs.perlin2(x, y) returns a value from -1 to 1.

The example capx translates that to a value from 0 to 100 for opacity. You could just as well set it to 100 or 0 by comparing if the value of noisejs.perlin2 is greater than 0. That would give blocks or no blocks instead of smooth noise.

The parameters x and y should be non integers to give differing values. That is why the example divides loopindex("x") and y by 10 in the expression. I guess that can be thought of as a scaling factor. If you use just integers you'll get just 0 returned.

Now that we've got some of the low level stuff out of the way the idea to create hills instead of just blobs is by combining perlin noise with something else. This link shows to combine the perlin noise with a vertical gradient to get the hills. After that the rest of the info loses me, probably because it's for some noise library.

Ok to use that let's do what the example capx does and loop over all the squares. This can be done any way you want whether with an array or no. It makes little difference.

- Code: Select all
`width = 100`

height =100

noise_scaling = 1

for x from 0 to width-1

for y from 0 to height-1

---- solid?

So your perlin noise at every point would be:

noisejs.perlin2(x/width, y/height)

or with scaling noisejs.perlin2(x/width*noise_scaling, y/height*noise_scaling)

We also only want block or no block instead of shades of blocks so we can just place a block if the perlin noise is greater than 0. It would then look like this:

- Code: Select all
`width = 100`

height =100

noise_scaling = 1

for x from 0 to width-1

for y from 0 to height-1

noisejs.perlin2(x/width*noise_scaling, y/height*noise_scaling) > 0

--- create block

So far so good but that just gives blobs everywhere. A solution is to add a vertical gradient to it.

This can do it: lerp(-1, 1, y/height). It will give -1 for the top 0 for the center and 1 for the bottom. So you expression is now

noisejs.perlin2(x/width*noise_scaling, y/height*noise_scaling) + lerp(-1, 1, y/height)> 0

Which will give more or less hills centered vertically.

There's probably more you can do such as shift it up and down by adding a number but the general thing to do is fiddle with the numbers and experiment until you get something you like.