Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Perlin noise that looks like this  (Read 7277 times)
0 Members and 1 Guest are viewing this topic.
Offline CptSpike
« Posted 2014-10-13 13:01:48 »

Hey all,

I want to create Perlin noise that looks like this:


From what I can generate, that looks like this: (How do I shrink this on the forums?)


I'm unsure what settings I need to tweak. I'm using this  Pointing to generate my noise. Any help is greatly appreciated.  Cheesy
Offline LiquidNitrogen
« Reply #1 - Posted 2014-10-13 13:15:26 »

Looks like the absolute value of 2 combined frequencies.
Offline DarkCart

JGO Kernel


Medals: 124
Projects: 9
Exp: 50 years


It's all in the mind, y'know.


« Reply #2 - Posted 2014-10-13 13:18:33 »

[offtopic]
Use [img width = "(Width here)"]http://(Link)[/img] to shrink images on the forums
[/offtopic]

The darkest of carts.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CptSpike
« Reply #3 - Posted 2014-10-13 14:38:25 »

Looks like the absolute value of 2 combined frequencies.

So I should create two images with two different frequencies? Then add the values at the same points, Math.abs() them, then clamp them so they're between 0 and 1?
Offline CptSpike
« Reply #4 - Posted 2014-10-13 14:38:53 »

[offtopic]
Use [img width = "(Width here)"]http://(Link)[/img] to shrink images on the forums
[/offtopic]

Ta muchly
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 486
Exp: 7 years



« Reply #5 - Posted 2014-10-13 15:12:22 »

http://gamedev.stackexchange.com/questions/20880/simple-noise-generation

First answer seem to be that exact image.
Offline CptSpike
« Reply #6 - Posted 2014-10-13 15:21:42 »

Thanks @BurntPizza! Bear with me for being slow, but in the following code:

1  
2  
3  
4  
5  
6  
double turbulence(double x, double y, double z, double f) {
    double t = -.5;
    for ( ; f <= W/12 ; f *= 2) // W = Image width in pixels
        t += abs(noise(x,y,z,f) / f);
    return t;
}


I'm guessing f is frequency?

EDIT: gah, I'm starting to pull my hair out over this. Cannot seem to generate that type of noise no matter what I try Sad
Offline philfrei
« Reply #7 - Posted 2014-10-13 19:18:09 »

Playing around with http://hexara.com/SimplexVisualizer.html I got the following, which seems pretty close.


Here is a screen shot of the settings I used:



Basically, what @LiquidNitrogen and @CptSpike is correct. The noise() function returns values between -1 and 1, and we want to scale the results to something like 0 to 255 for graphics output. The method of scaling used for your example includes an absolute value. This form of mapping was termed "Turbulent Noise" by Ken Perlin.

For example, (pseudo code)
1  
2  
3  
4  
5  
for ( all y values)
  for ( all x values)
     noiseValue = noise(x * xScaling, y * yScaling);
     noiseValue = Abs(noiseValue) * 255;
     postValueToImagePixel(x, y, noiseValue);


A "Smooth Noise" mapping would be more like the following:
1  
  noiseValue = ( (noiseValue + 1) / 2.0 ) * 255;


I don't know about your particular noise() function, or why you are putting 4 parameters in it. With Gustavson's Simplex Noise implementation, you only need the X & Y for 2D noise.

Your pattern might have a bit of "clamping" to it on the black end. That can be accomplished by something like the following:

1  
2  
3  
    noiseValue = abs(noiseValue);  // applies 'turbulent noise' algo
    noiseValue = ( noiseValue * 1.2 ) - 0.2; // scale and shift
    noiseValue = max(0, noiseValue);  // "clamp" levels below 0 to 0



Another possibility is that the multiplication in the second step above is omitted, and the values simply shifted downward with the subtraction, then clamped. I say that because it seems to me the results don't get as bright as I expect at the white end, so maybe the shift was uniform across the entire response range, rather than being "stretched" by the multiplication first.

There may be a second noise function being summed in, in which case the noiseValue starts out as the weighted sum of the two calls to the noise() function, before going through the various transforms to make the number an intelligible color value.

You can download the jar of Sivi from here:
http://www.java-gaming.org/user-generated-content/members/27722/sivi.jar
Or, check out the github open source here:
http://github.com/philfrei/SiVi

music and music apps: http://adonax.com
Offline philfrei
« Reply #8 - Posted 2014-10-13 19:27:04 »

Just thought I'd add a note about "frequency". It is probably the most confusing thing for people first trying to understand how to use the noise() function.

In the pseudocode in the previous example, I wrote the following:
1  
 noiseValue = noise(x * xScaling, y * yScaling);

The "frequency" is referring to the amount of scaling used on your X & Y values before making the method call. One reason for the use of the term is that folks like to make the combination of noise() methods a fractal process, thus each "frequency" is set to be an octave (or doubling or halving) of another.

music and music apps: http://adonax.com
Offline CptSpike
« Reply #9 - Posted 2014-10-13 20:46:53 »

Thanks for the help @philfrei, I'd forgotten about the coordinate scaling business. I'm going to have a fresh start at this tomorrow, I'll report back if I ever get it working properly Smiley

EDIT: @philfrei, I borrowed your SimplexNoise class from the project you linked, and followed the code in your comment, but I'm just getting random noise, like this:

Full size image
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jmguillemette
« Reply #10 - Posted 2014-10-14 15:00:46 »

To get an image like you want.. you want to run the perlin routine at different levels and them merge the results.


-=Like a post.. give the author a medal!=-
Offline CptSpike
« Reply #11 - Posted 2014-10-14 15:16:56 »

To get an image like you want.. you want to run the perlin routine at different levels and them merge the results.


Still no dice. Gah how can I be so bad at this, it's only parameter twiddling.
Offline LiquidNitrogen
« Reply #12 - Posted 2014-10-14 15:31:49 »

You might be dividing the x and y by way too much, you want fairly low frequency noise to produce those loops
Offline philfrei
« Reply #13 - Posted 2014-10-14 16:32:53 »

You might be dividing the x and y by way too much, you want fairly low frequency noise to produce those loops

Actually, I'm guessing the opposite is the case, not dividing by enough.

To get lower frequencies, the rate at which one moves through the Perlin space has to be pretty small. Therefore the increments between one X and the next have to be very small. I'd try dividing X & Y by 64 or 32 to get something in the ballpark of what I displayed.

The "base" scaling factor in my app is 1/256 if I remember correctly, and the example I put up was 6 times that.

So try this:
1  
 noiseValue = noise( (x * 6) / 256.0, (y * 6) / 256.0);  

Or put in a simpler expression like (x / 43.0, y / 43.0);, and be sure and make the division result in a double, don't do integer division.
If you are using Gustavson's SimplexNoise, that should get you pretty close.

music and music apps: http://adonax.com
Offline philfrei
« Reply #14 - Posted 2014-10-14 17:02:08 »

Yesterday I thought I posted another round of playing with this--but I must have bungled it, as the post isn't here. I couldn't resist trying to reverse engineer your example.

Here is the screen shot:


I realize this is over-complicating things a bit, as you are still trying to get the basic function to produce the result on the top right. But I am confident you will get it when you try putting in a scaling factor like I described in the previous post.

In this example, the refinement is that a lower frequency is added (scaled to half of the main track), but I'm first clamping out all the negative values instead of folding them over back into the positives via the ABS function. So, overall, it is providing some nice shading with some "highlights" here and there where the white appears.

The equation for the left side (noiseValueA) in combination with the right side (noiseValueB) would be this:

1  
2  
3  
4  
5  
6  
    noiseValueA = Math.max(0, noise(x * 3 / 256.0, y * 3 / 256.0);
   
    noiseValueB = noise(x * 6 / 256.0, y * 6 / 256.0);
    noiseValueB = Math.abs(noiseValueB);

    noiseValue = (noiseValueA + 2 * noiseValueB) / 3;


Then, transform noiseValue into a meaningful color value, and assign it to pixel (x, y).

music and music apps: http://adonax.com
Offline CptSpike
« Reply #15 - Posted 2014-10-14 17:53:53 »

Yeees! I was multiplying by a factor, instead of dividing, and it was much to small. Dividing my coordinates by 128 gives me this:

Thanks so much for your help everyone, was about ready to give up on this. Hopefully some tweaking will finally give me what I can use Smiley

EDIT: Finally got to where I was trying to go. Big thanks to everybody for their help. Now I have terrain for my worms clone! Exmaple:
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (578 views)
2019-09-04 15:33:17

hadezbladez (5495 views)
2018-11-16 13:46:03

hadezbladez (2398 views)
2018-11-16 13:41:33

hadezbladez (5756 views)
2018-11-16 13:35:35

hadezbladez (1219 views)
2018-11-16 13:32:03

EgonOlsen (4659 views)
2018-06-10 19:43:48

EgonOlsen (5667 views)
2018-06-10 19:43:44

EgonOlsen (3193 views)
2018-06-10 19:43:20

DesertCoockie (4093 views)
2018-05-13 18:23:11

nelsongames (5104 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!