Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 questions  (Read 4194 times)
0 Members and 1 Guest are viewing this topic.
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Posted 2012-11-03 18:42:37 »

Hello, im having troubles again haha Smiley

Im using standard perlin noise to render some heightmaps and stuff, nothing big.

But now im trying to use perlin noise to generate clouds (no cloud maps, but island like):


Also im trying to add turbulence to an circle like this:
Click to Play


But i cant figure out how these methods work, i tried various stuff (with horrible output), and searched loads of thread, but most people just use an library.
Simply using an library wont really help me understanding, so i hope i can find some help here.

So can someone point me to some good resorces or give some basic explanation?
Thanks for reading anyways.
Offline Grunnt

JGO Wizard


Medals: 79
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #1 - Posted 2012-11-03 19:47:06 »

I'm far from a math expert, but I just used a perlin-noise thing in my game, based on a SimplexNoise (like Perlin noise, only faster). Here's the code I used as inspiration / starting point (originally from Stefan Gustavson, Linköping University):

http://webstaff.itn.liu.se/~stegu/simplexnoise/SimplexNoise.java

p.s. I expect that really understanding this will be quite a task..

Offline Danny02
« Reply #2 - Posted 2012-11-03 20:31:18 »

once apon a time there was a link on twitter from aras_p where he showed of a procedural explosion effect done only in the pixel shader in a webgl example which is now used in unity i guess.
sadly I couldn't find the link anymore Smiley


update found something similiar it:http://www.clicktorelease.com/code/perlin/explosion.html
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #3 - Posted 2012-11-04 12:13:26 »

I'm far from a math expert, but I just used a perlin-noise thing in my game, based on a SimplexNoise (like Perlin noise, only faster). Here's the code I used as inspiration / starting point (originally from Stefan Gustavson, Linköping University):

http://webstaff.itn.liu.se/~stegu/simplexnoise/SimplexNoise.java

p.s. I expect that really understanding this will be quite a task..

I have implemented simplex noise already but it just creates maps like this:


I really want one randomized and centered blob. (so there are no edges visible at the borders of the image).

once apon a time there was a link on twitter from aras_p where he showed of a procedural explosion effect done only in the pixel shader in a webgl example which is now used in unity i guess.
sadly I couldn't find the link anymore Smiley


update found something similiar it:http://www.clicktorelease.com/code/perlin/explosion.html
http://www.webgl.com/wp-content/uploads/2012/07/webgl-fireball-explosion-2.jpg

Thank you, but this guy is using some librarys to archive this.

I just want to know the theory of adding turbulence to an circle and generating an random blob.
I dont get how this is done from basic perlin (or simplex) noise.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2012-11-04 12:51:09 »

Bout that, I know there are algorithms for generating islands which are surrounded by water, so I googled for "island generation noise" and found this:
http://breinygames.blogspot.de/2012/06/generating-terrain-using-perlin-noise.html
the intresting part is the "Island map". Propably not a fast algorithm, but maybe there are others (I'll go and google-fu more...). Also, he has a link to the google project, so you could check out the source... (python! eeeew...)

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #5 - Posted 2012-11-04 17:39:27 »

Bout that, I know there are algorithms for generating islands which are surrounded by water, so I googled for "island generation noise" and found this:
http://breinygames.blogspot.de/2012/06/generating-terrain-using-perlin-noise.html
the intresting part is the "Island map". Propably not a fast algorithm, but maybe there are others (I'll go and google-fu more...). Also, he has a link to the google project, so you could check out the source... (python! eeeew...)

Found this one to, the problem is he only uses perlin noise in his first (failed try).
In his solution he chooses an random pixel and increases the value, then the neightbour etc (like lightning, but only one direction).
He does this with an x amount of pixels, until an island is visible.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #6 - Posted 2012-11-04 17:52:21 »

Bout that, I know there are algorithms for generating islands which are surrounded by water, so I googled for "island generation noise" and found this:
http://breinygames.blogspot.de/2012/06/generating-terrain-using-perlin-noise.html
the intresting part is the "Island map". Propably not a fast algorithm, but maybe there are others (I'll go and google-fu more...). Also, he has a link to the google project, so you could check out the source... (python! eeeew...)

Found this one to, the problem is he only uses perlin noise in his first (failed try).
In his solution he chooses an random pixel and increases the value, then the neightbour etc (like lightning, but only one direction).
He does this with an x amount of pixels, until an island is visible.

No, he uses Perlin noise in the first as well as in the second try.
In the second try he multiplies the "Island map"'s values by the Perlin noise values, which one could call combining the two maps.
So... He basicly uses both Perlin Noise and a Island map.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline philfrei
« Reply #7 - Posted 2012-11-04 18:58:47 »

I've been working on a tutorial on how to use, as a way to teach myself about it. I'm still learning and experimenting myself about this.

http://hexara.com/SimplexBuilder.html

The last section that I've gotten to starts to describe the types of modulations you are asking about, but for a vertical gradient, not a radial or an island shape so much. (The "Terra Map" section deals a bit with islands.)

In brief, I think you need to combine the randomizing effect of the noise with another equation or functions that makes the core shape you are going for.

For the radial effect, for example, lets say you have a function that goes from 1 in the center to 0 at the radius. Have these numbers "modulated" (Perlin's term) by the noise via addition would be a solution. It the noise ranges from -0.25 to 0.25, and you use a min and max to stay within 0 to 1, adding will create a randomized field of values, also from 0 to 1 but with a fair bit of randomness in the transition.

Then, of course, you make the 0 to 1 values map to your colors, etc.

Here is a graphic that has my first attempts at this. I'm looking forward to taking the time to nail that solar flare example from Perlin's slide show, and the animation of it.





I should try drawing a black circle over it...

This next link is an animation of the flames that is in the tutorial segment I am currently working on. It kinda works. Like I said, I'm new to this, too.
http://hexara.com/SimplexFlames.html


If you have a specific island shape in mind, you can work off of that, or I guess it is also possible to generate random "islands" by using the noise and clipping the output in some fashion or another. For example, the output is -1 to 1, and lets say you get a good island if you used only the values above 0.7. Add an operation like this:
1  
    if (noiseVal < 0.7) noiseVal = -1;

And then use other scaled amounts of noise to modulate those island values again with some sort of clipping to eliminate modulation of the ocean areas.

That is just an idea off of the top of my head. There are probably other was as well to get the results you want. If you have a good grip on how the numbers are generated and used, you can make them do all sorts of shapes. I try to make this all clear in the tutorial.

And if the tutorial text isn't clear, I'd sure appreciate feedback for improvements!

I'm also thinking of further development of the tool and open sourcing it, so that the "visualizer" portion can be used to generate useable code.

"It's after the end of the world! Don't you know that yet?"
Offline philfrei
« Reply #8 - Posted 2012-11-04 19:41:38 »



It seems I need to fine tune the relationship of the radial gradient to the noise a bit still. Maybe too much amplitude at the low octaves. But it is in the ballpark.

"It's after the end of the world! Don't you know that yet?"
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2012-11-04 20:16:27 »

Great work!

Some things you should do: Do this noise in 3 Dimensions, to make it animate, and also multiply each 2D-layer of the animation by a value, which is low in the beginning layers, getting higher to the mid, and getting lower to the end.

For example assume you need a 512x512 pixel explosion effect, which has 32 animation frames.
Then you'd create the radial mask (or use the island-noise), and multiply each layer by the mask's values or add them to each layer.
And then use an (propably cubic) interpolated number to multiply each layer by, which is for example 0 for the first frame, interpolated to 1 in the 24th frame and going down to 0 in the 32nd frame.

I'm just trying to do that too now Smiley

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Danny02
« Reply #10 - Posted 2012-11-04 20:18:33 »

to get a good circle shape for your sun.
you could try polar coordinates
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #11 - Posted 2012-11-04 20:22:50 »

to get a good circle shape for your sun.
you could try polar coordinates

So... you create 1 Dimensional noise, which changes the outline of a circle?
So the outline of the circle sometimes is more far from the middle of the circle than others...

So r(θ) = 16 + (4 * noise(θ)) ?

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #12 - Posted 2012-11-04 22:54:23 »

I've been working on a tutorial on how to use, as a way to teach myself about it. I'm still learning and experimenting myself about this.

http://hexara.com/SimplexBuilder.html

The last section that I've gotten to starts to describe the types of modulations you are asking about, but for a vertical gradient, not a radial or an island shape so much. (The "Terra Map" section deals a bit with islands.)

In brief, I think you need to combine the randomizing effect of the noise with another equation or functions that makes the core shape you are going for.

For the radial effect, for example, lets say you have a function that goes from 1 in the center to 0 at the radius. Have these numbers "modulated" (Perlin's term) by the noise via addition would be a solution. It the noise ranges from -0.25 to 0.25, and you use a min and max to stay within 0 to 1, adding will create a randomized field of values, also from 0 to 1 but with a fair bit of randomness in the transition.

Then, of course, you make the 0 to 1 values map to your colors, etc.

ec...

Thanks!
I didnt expect it was that easy, i thougt about this option, but thought it would be ugly.

My cloud:


No i can experiment with this function to create the nice solar flares and plasma clouds.
Also transforming objects will be possible, like smashing an sphere untill it looks like an astroid.
Really awsome, this was exact what i was looking for.

My code to change an circle to an cloud:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
    private static SimplexNoiseGenerator gen = new SimplexNoiseGenerator((long)(Math.random()*Long.MAX_VALUE));
   
    public static Texture genCloud(float diameter){
        BufferedImage b = //create image
        int[] pixels = ((DataBufferInt)b.getRaster().getDataBuffer()).getData();
        int acces;
        float radius = diameter * 0.5f;
        float smallradius = diameter * 0.4f;
       
         for(int x=0; x<diameter; x++){
            for(int y=0; y<diameter; y++){
                    float value = genPixel(x - radius, y - radius, smallradius);
                   
                    acces = x + y*200;
                    pixels[acces] = new Color(1f, 1f, 1f, value).hashCode();
            }
        }
       
        try{
            //Generate texture
        }catch(Exception ex){ return null; }
    }
   
    private static float genPixel(float x, float y, float radius){
        float dist = 1 - (SimpleMath.dist(x, y) / radius);
        float val = (dist + (float)gen.noise(x*0.01, y*0.01, 0, 5, 3, 0.4f)*0.35f);

        //gen.noise(x*0.01, y*0.01, 0, 5, 3, 0.4f) explained:
        //x, y, z, octaves, frequency, amplitude.


        return SimpleMath.clamp(val);
    }
Offline philfrei
« Reply #13 - Posted 2012-11-04 23:59:35 »

Nice.  Smiley

by the way, where did you get the graphic of the cloud on your first post? I recognize the solar flares from Perlin's slide show. The cloud is rather remarkable, and I am do not know how to generate it. In particular, the edge is so much more distinct and smooth than is usual.

Also, there are some definite directional lighting effects. Was the graphic accompanied by an article?

"It's after the end of the world! Don't you know that yet?"
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2012-11-05 00:32:44 »

The cloud in the first post is most likely a ray traced volumetric noise, and maybe post-processed and rendered with sprites (textures with puffs of smoke).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online Roquen
« Reply #15 - Posted 2012-11-05 08:57:40 »

If you're going for realistic, then the your going to need to go with some light scatter model.  If you want to muck with some pure noise solution, then you could try using the same "trick" as pure noise marble.
Offline Danny02
« Reply #16 - Posted 2012-11-05 11:36:13 »

a quite "simple" way to generate 3d volumetric smoke with noise(so no fluid simulation with massiv particles) can be done as following:

-render in a deffered(normal+depth) way some smoke bubbles (simple spheres)
-displace the gbuffer with 3d noise, taking as input the world positions
-render the smoke, additional to the normal direct lighting one can use the smoke thikness to apply some simple scattering effect.

some smoke I did some years(?) ago
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #17 - Posted 2012-11-05 12:55:00 »

The cloud is made by someones custom engine i guess..
Found it in someones showcase: http://www.peterkutz.com/
Offline philfrei
« Reply #18 - Posted 2012-11-05 20:40:21 »

@RobinB -- thanks for the link! That fellow has done some interesting work. I can't offer any further insights as I have done nothing with 3D yet.

@riven -- you were right about the volumetrics

@Danny02 -- nice cloud! But I am at a loss to follow your explanation as to how you created it. I'm thinking more will become clear when I have time to study 3D graphics more, learn what these volumetric processes are all about.

@Roquen -- "light scatter model" -- again probably more 3D stuff for me to get to, pertaining to shaders and the like? But what are you referring to when you use the term "marble" in the noise context? Is this specifically the ribbons that can result with the use of a sin function? Or with the use of the abs function (turbulent noise)?

OK, I can hear people saying: did you try searching on the question?
Yep. Found this:
http://physbam.stanford.edu/cs448x/old/Procedural_Noise%282f%29Perlin_Noise.html
Lot's about marbling there!

One can create marbling by embedding it in a color map. I supposed it would be possible to make the map marbling colors be ribbon based and have the two sides mimic shading...

I did try messing around with my settings for the solar flare and got something closer to Perlin's example. I think it still needs a couple more octaves to improve the detail. The image is doubled since my 256 field is kind of small.

I intend to put the settings into the tutorial, to allow people to click it up in the tool and tinker with it. (Though it won't have the dark circle in the center.)


"It's after the end of the world! Don't you know that yet?"
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #19 - Posted 2012-11-05 21:30:25 »

Nice work, wish i could do that with my generated stars, but 20 textures of 2000 x 2000 is a bit to much (with some creative shading i could bring it to 5 textures, but its still a lot).
Instead i expanded my function to create an map of random clouds to render;



Those are red, because it should be something like gas clouds (in space).
The color is going to be random (for groups of clouds).
Offline Danny02
« Reply #20 - Posted 2012-11-05 21:37:49 »

I see that you already got some really nice smoke clouds. Even if they look quite nice how they are some lighting can improve the visuals dramaticly. Think about a rocket going threw a cloud and illuminating it from within.

here is a nice paper about smoke rendering, just how to lighten smoke not so much how to create the shape.
http://www2.imm.dtu.dk/visiondag/VD06/graphical/smoke.pdf

The presentation is quite easy to understand and has some usefull tipps.
On the second last slide it is shown how to create a smoke volumn with a modeling tool and photoshop, the same can be done in realtime of course Wink

ps: thinking about old times, lets see if I can put together a quick demo
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #21 - Posted 2012-11-05 22:16:10 »

Thank you, it makes some things more clear, but these psychics are applying on small scale clouds.
The clouds trough the universe would be less influenced by any light sources.
But this is something cool to experiment with using the sun as light source on these clouds.
Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #22 - Posted 2012-11-06 17:06:03 »

here is a nice paper about smoke rendering, just how to lighten smoke not so much how to create the shape.
http://www2.imm.dtu.dk/visiondag/VD06/graphical/smoke.pdf

The presentation is quite easy to understand and has some usefull tipps.
On the second last slide it is shown how to create a smoke volumn with a modeling tool and photoshop, the same can be done in realtime of course Wink

GENIOUS!
I even understood everything Smiley
Very good paper...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #23 - Posted 2012-11-06 17:45:38 »

I did some experiments with fake back lighting / scatter on 2d clouds ages ago that turned out really well:



This is mostly just a bit of fancy (offline) pre-processing and a simple shader to do the lighting, which makes it really fast. I think it ended up looking a whole lot better than the more traditional approach of trying to generate the normal map of the composite sprites at runtime.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!