Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
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  
  Appending Perlin maps  (Read 813 times)
0 Members and 1 Guest are viewing this topic.
Offline James van Dalen

Senior Newbie





« Posted 2013-10-15 08:23:45 »

Hey everyone, got a bit of a question.

I am using a perlin noise function to generate a map of some form, i don't mean to be vague but I am such a newbie with noise generation that I don't actually know how to explain the question in full...

My perlin noise code comes from this site if it helps any: devmag.org.za/2009/04/25/perlin-noise/

My question is, how can I make a tiled noise (i know it's been asked but every one they assume "tiled" means to make it copy paste side by side...) as in I make a map with say 100 width and 100 height... but I want to make another 100x100 map to append to either one of the 4 sides and make it seem as though it was always meant to be a 200x100 map...

sorry if my explanation is not 100% right but hopefully you can help me at least with starting off in the right direction.

Note: I don't want to make 1 tile that just repeats over and over, I want to make tiles that merge with the one next to it, like the left map which has half a lake will have the other half on the right map

hope that's clear enough, thanks everyone anyways oh and also I can't put pictures or code or links because I am using my phone to post this.
Offline Roquen
« Reply #1 - Posted 2013-10-15 09:17:16 »

Most techniques for making wrapping noise are both broken and very expensive.  The correct way to do it is to have the hash values match at the boundaries...which from a practical standpoint means making some custom noise kernels.
Offline philfrei
« Reply #2 - Posted 2013-10-15 09:21:32 »

First a bit of pedantry. The site you have linked seems to be demonstrating some form of value noise, not Perlin noise. Below is the best paper I've found on the subject, which includes a java implementation of Simplex noise. Simplex nosie was the 3rd iteration (and possibly the "best") by Ken Perlin of his technique.

"Simplex Noise Demystified" by Stefan Gustavson
http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

(Ah, I see the author of your article realized that this isn't Perlin Noise, and is similarly unsure what it is exactly that he has created!)

With one of Perlin's noise functions, you would just continue translating the x and y for adjacent tiles. So, if the first tile has X ranging from 0 to 99, and Y from 0 to 99, the next tile to the right would be X: 100 to 199, Y: 0 to 99.

There is a factor that you have to multiply to get the base frequency before plugging into the noise function. I like 1/256 or 1/128. Then octaves are created via multiples of this base, pretty much as is done in your article link.

1  
noiseVal = SimplexNoise.noise(x * (oct / 256), y * (oct /256));  


In the above case, x & y are the normal 2D coordinates based on the origin, which may be an arbitrary number of tiles away.

There's some useful info on textures and noise in jgo's wikis and other threads as well. I recommend searching our site. Here's a particularly good one:
http://www.java-gaming.org/topics/noise-bandpassed-white/27071/view.html

Not sure I'm ready to jump in and try to figure out how to do what you want with your article's algorithm. Perhaps it is just a matter of continuing to pre-make more reference arrays to match the total space you wish to have in your game.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2013-10-15 09:21:58 »

Follow-up: I just looked at the page you mentioned.  That's (yet again) NOT perlin noise.  See the local wiki page. 

(EDIT: ninja'd yet again)
Offline CodeHead

JGO Coder


Medals: 35


From rags to riches...to rags.


« Reply #4 - Posted 2013-10-15 09:25:45 »

Just for my curiosity, since I've recently started looking into Perlin noise as well, I'll ask a bit of a naive question. Couldn't the separate tiles be blended much in the same way that you'd make a seamless single tile, except instead of blending the opposing edges (top/bottom, left/right), you'd blend the touching edges of the individual tiles? Still fairly new to implementing procedural textures, so pardon the depth level of ignorance this question may reach. persecutioncomplex

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline James van Dalen

Senior Newbie





« Reply #5 - Posted 2013-10-15 09:30:28 »

yeah I read another article on this site that said perlin noise is often mistaken by value noise... However I really cannot tell the difference... fractal noise, value noise and perlin noise all look the same to me...
Offline Roquen
« Reply #6 - Posted 2013-10-15 09:31:52 »

My first response was making the assumption that reusable tiles are been generated.  "Blending" is broken from a signal processing standpoint...that wouldn't matter except it does usually look bad.  Depending on what the tiles are being used for, then a Wang tiling technique is an option (not nec.  a non-periodic tiling).

Look at the webgl demo I linked in the wiki for visual differences.
Offline Grunnt

JGO Wizard


Medals: 55
Projects: 9
Exp: 5 years


Complex != complicated


« Reply #7 - Posted 2013-10-15 09:35:55 »

What philfrei said, just generate the appended map in exactly the same way as the original map, by linearly increasing the x and/or y values to fit the appended map's location.

Offline philfrei
« Reply #8 - Posted 2013-10-15 09:41:13 »

@CodeHead
Ken Perlin has an example of where he loops some noise (for a cloud animation), but wants it seamless. His technique for getting a smooth effect is given at the following link:

http://www.noisemachine.com/talk1/24b.html

It seems to be a normal sort of linear blending function. Any two tiles could be blended this way, it seems to me, if you allow for an amount of overlapping data. But with Perlin space functions, I think it makes more sense to just keep translating to whatever location.

Actually, as I look at the math again, I think I was wrong. I'm going to have to figure out what this equation is doing.

[EDIT: Looked at the math, and the Z value is just a simple linear blend.]

I definitely defer to Roquen in terms of expertise and understanding of all this.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline James van Dalen

Senior Newbie





« Reply #9 - Posted 2013-10-15 09:43:52 »

well I suppose to give the question a but more of a standing point... minecraft generates its terrain in chunks of 16x16 blocks, right.  I am only interested in how they managed that, I doubt they made a massive map and just portioned it off... and I realise they probably use many layers of noise but I only want to know that top piece with the sea beach, land, grass and all that...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #10 - Posted 2013-10-15 09:47:28 »

Oh yeah.  On that WebGL demo...the thing is that defects are less likely to be noticeable when noise is used this way...to generate a diffuse map (color) texture.  If you start generating height-maps, normal maps, perturb surfaces, etc is when the problems start to become more apparent.  Value noise can be adequate in quite a few situations...but like mentioned on the wiki page it might well be more expensive since it can require more samples to achieve the same visual complexity.  All of this boils down to how much of your time out want to spend on a given effect and how expensive that effect is.

Back on blending...even when you succeed in not having defects from the blending, you're still paying the cost of drastically increasing the number of noise samples that need to be generated.
Offline James van Dalen

Senior Newbie





« Reply #11 - Posted 2013-10-15 09:51:42 »

is there an example on how to do this, linear hash border thing?
Offline CodeHead

JGO Coder


Medals: 35


From rags to riches...to rags.


« Reply #12 - Posted 2013-10-15 09:53:16 »

@philfrei
I've browsed Ken's presentation a few times as well as watching some talks from him. It's going to be one of those things that will have to ferment in the back of my mind before I get it (curse my lack of math prowess). persecutioncomplex At least I know which part to concentrate on for the tiling aspects. Much obliged. Grin

@Roquen
I had a feeling it wouldn't be as simple as I had hypothesized. Wink

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline Roquen
« Reply #13 - Posted 2013-10-15 11:06:11 »

I've been attempting to motivate myself to do a write up on this kinda stuff (since the before the wiki started...so don't hold your breath)

WRT: hashing - personally I wouldn't do it this way, however most people are likely to find it to be the easier option.  Skim the wiki page on how noise kernels work.  Basically you end up limiting yourself to having an integer number of cells for all sampling octaves that fit within a tile and are performing a modulo so all the hash values along a matching edge end up matching on opposite sides.  At the cheapest (and most restrictive) this becomes an AND masking.  (As an aside CGI for ages was limiting itself to a domain of [0,255] so that part shouldn't be a big concern).  The downside here is that you limit the frequencies of sampling which are available.  Not since I haven't done any real thought in this direction for ages I might be forgetting some scaling trickery.

Personally I'd do something different.  To generate a 2D set of tiles I'd sample a 3D noise function in a pattern to make edges match.  You lose the frequency restrictions and each octave can be chosen anywhere in the domain, but have to think up the sampling and no longer have simple top-to-bottom & right-to-left tiling.  This last is a good thing.  Junk like this really needs a write up with pictures and stuff...meh.
Offline Roquen
« Reply #14 - Posted 2013-10-15 13:27:30 »

Oh yeah...and since this under Newbie I'll give some extra details.  By tiling we're only taking about tiles which are reused to build up things an not any other notion of tiles.  Also I'm blowing off blending as being defective...that doesn't matter in the slightest if they aren't noticeable.  And I'm also saying that it's expensive...doesn't matter in the slightest if the process is at production time and very unlikely to matter if at loading/generation time.  If most to all of what I'm saying is sailing over your head...file it in the back of your brain and forget about it for now.  Understanding the math and theory behind noise etc is handy...but it's also very artistic...so goofing around is at least if not more important.
Offline philfrei
« Reply #15 - Posted 2013-10-15 20:56:22 »

@James van Dalen
I'm thinking that maybe the article you read got you off on the wrong foot, conceptually, in terms of understanding Perlin noise. Your article talks about generating an array of random values at the start for a given tile. With Perlin noise, the randomness is built into the function call, and it works for the entire domain of computable numbers, returning a given value between -1 and 1 for any set of inputs. Then, the usual thing is to translate the [-1, 1] set of numbers to [0, 1] either by scaling and translation (smooth noise) or by applying an abs function (turbulent noise). Last step: applying the normalized numbers to either color values or to a mapping function (where the mapping can be to anything, including terrain types). An explanation I wrote of these basics (you may be beyond the basics already) at the following post was "appreciated" a couple times, so it might be worth a look if the above is unclear.

http://www.java-gaming.org/topics/noise-implementation/30868/msg/285683/view.html#msg285683


@CodeHead
Thanks! I also found the Perlin talk very difficult to digest, to translate into actual code. My math is not that great either, but Perlin's writings, I think, are generally considered on the terse, compact side. I really recommend looking at the Gustavson paper. It is very readable, helpful. Also, coding the "visualizer" app (so one could play around artistically) with the goal of recreating some of the effects on the Perlin talk gave me some practical insights. You can play with it, too, at http://www.hexara.com/SimplexBuilder.html

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline CodeHead

JGO Coder


Medals: 35


From rags to riches...to rags.


« Reply #16 - Posted 2013-10-15 22:36:37 »

@philfrei
I've passed many a moment tweaking with that applet before. Excellent job. Grin Out of curiosity, are you using "classic" Perlin noise, or the newer Simplex noise implementation? I ask due to you citing Ken's older presentation, but you app has "Simplex" in the name. Smiley

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
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.

xsi3rr4x (48 views)
2014-04-15 18:08:23

BurntPizza (44 views)
2014-04-15 03:46:01

UprightPath (60 views)
2014-04-14 17:39:50

UprightPath (42 views)
2014-04-14 17:35:47

Porlus (58 views)
2014-04-14 15:48:38

tom_mai78101 (82 views)
2014-04-10 04:04:31

BurntPizza (140 views)
2014-04-08 23:06:04

tom_mai78101 (240 views)
2014-04-05 13:34:39

trollwarrior1 (200 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!