It looks like you're new here. If you want to get involved, click one of these buttons!

Hi All,

I have dabbled with noise - Perlin, simplex etc and used a few methods to design heightmap. With the arrival of Craft the noise functions have been significantly improved with lots of options to play with. Another star for Craft. But, unfortunately I’m not a mathematician and my early attempts are very crude. What I’m looking for is how to use coherent noise - example calls and the noisegradients you can generate.

Anyone got any ideas ?

Tagged:

## Comments

@Bri_G The different noise functions just return different values for the same input values. The example below shows the same input x,y,z values for 3 different noise functions. The output results from them are different. To see a better representation, a 3 dimensional grid should be used.

@Bri_G I thru together this 3D graph of some noise functions. When you run this, it takes a few seconds before the graph displays. To see the different noise results, uncomment each noise function in the for loops. The grid calculations are from x -1 To 1, y -1 To 1, and z -1 to 1 in steps of .2 . The y value is replaced with the calculation from the noise function to show the different noise values.

@dave1707 - thanks for that. Tried those out but ran into a problem when I tried to use craft.noise.constant() which threw up an error even with a value in the parentheses a la reference. Tried n:getValue(x,y,z) as against n(x,y,z) and the output noise.constant printed.

Being naive I thought noise was just another random function and expected to get random output. But that’s not the case - you get the same output every time from the same input. They are just mathematical functions that give different output from different input, but reproducible. Just need to bend them to our needs.

Trying to apply the features of lib.noise a la their website

Libnoise

What I’m trying to get my head round is coherent-noise.

@Bri_G From what I know about coherent noise is:

It’s like playing a CD. If you play the same CD, you get the same songs. If you turn up the volume a little, all the songs are the same but a little louder. If you turn up the volume a lot, it’s the same songs but distorted. Might not be a good example.

Here’s an updated 3D graphic of some Craft noise functions. Change the noise slider, then press calc to show the noise results.

@Bri_G I have other changes I’m going to make to the code, so I can add a switch that shows/hides the ground.

@Bri_G I added your suggestion in the code below. There’s a slider to show/hide the ground. I also added a slider to allow the noise function to use a value other than 0 for the y axis. That way you can see the differences with different starting y values.

@John

You may be able to answer this - regarding libnoise. In the Tutorial series, tutorial 3 shows the generation of a greyscale tile. It also shows a graph of the '

bounding rectangle' used for the generation. I can generate grey scale tiles without problem but and, as in a later tutorial, can produce tiles which extend the first tile matched at the interface.However the tutorial series suggested that the tiles will wrap so I was hoping the far right face on the second tile would wrap to match the first tile left face and bottom wraps with top faces. But that is not the case.

Could you explain what the dimensions used in the graphs are - they seem out of proportion to the scale of the images (ie 2 to 6 versus 1 to 256).

Also I am assuming I will have to write some blending routines too get the desired face overlaps - is that the case. You have already written some in the Planet generator example for Craft so I will base my routines on yours.

Could you also advise on the x,y,z parameter ranges for the calls to the noiselib. The tutorial looks like the x and z parameters are used - if so what is the y parameter. I've just fiddled with them to generate my maps and they seem to need low (<0.01) numbers.

Finally, some of the images I have generated seem to have colours in strange places. I have only used positive numbers in my coding - it looks like the craft.noise.perlin(x,y,z) call returns numbers between -1 and +1, is that the case. If so my code will need some adjustment.

By the way figured out the skybox now I can use it with obj models - looks awesome. Will post a vid later.

@Bri_G I went to the libnoise page and thought I’d write this. Here’s the prelim noise from -1 To 1 in steps of .0075. I’m changing the color based on a range of the results from the perlin noise function. Slide your finger up or down to change the z value into the perlin noise. When you lift your finger, it takes a few seconds to recalculate a new image.

@Bri_G If you’re wondering about frequency, I modified my program to allow you to change the settings for the perlin noise function. Just make a slider change, tap the screen to re-calc. @John The lacunarity value doesn’t work, is it the correct spelling in the documentation.

EDIT: Changed noise.perlin() to noise.billow(). Lacunarity works for the noise function billow but not for perlin. The parameter slider for lacunarity was uncommented.

@John The

`lacunarity`

works for noise.billow() and noise.rigidMulti() but not for noise.perlin() even though it’s listed for noise.perlin(). I don’t know if the documentation is wrong or perlin is wrong.Thanks again slowly making progress here. Do you know if you can enhance the tiles like the tutorials for lib noise by brightening and changing the contrast - thought there may be features within Craft to do it or some shaders.

Oops, meant say programmatically how do you adjust brightness and contrast in an image.

Looks like brightening is just multiplying each colour variable by a percentage. Contrast looks very similar. I thought you would graduate a change over selected ranges in the image for contrast. Think I’ll use Gimp or Affinity!!!

@Bri_G The -1 to +1 is just the x and y ranges. Think of graph paper where the x and y axis goes from -1 to +1. Then I just increment through all the x and y axis values by .0075 . Then think of the z level as some amount above or below the graph paper. Every point at an x,y,z value will get a number back from the noise.perlin function. So every point in a cube will get some value from noise.perlin.

@Bri_G Here’s a cube where I calculate the perlin value for each value from -1.2 to 1.2 for x,y,z at increments of .2 . I then take the perlin value at those points and assign it a color value for each sphere. Use 2 fingers for pinch, expand, or move to zoom in, zoom out, or move the cube. It looks interesting to zoom in and rotate the cube. I also show color text that gives the color range of the spheres and the values. It takes several seconds for the color spheres to show.

@dave1707 - aha so the value range of the noise.perlin output is used (your first/second examples) as the axes for x and y and your using the single output of the as the z value. My problem - not thinking in maths mode just thinking of a semi random value for the height in a heightmap for each x and y point.

Your third example is quite spectacular especially when you consider the array can be moved and expanded in real time and space - when you zoom into the array and move it around. Thanks again, time for me to try to use this.

@Bri_G All of the noise functions use x,y,z values as input and output a single value for that position. So any point in 3D space (x,y,z) has a noise value. By plotting the x,y values as a flat surface and the value returned by noise as the height, you can create unlimited landscapes.