Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
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 1891 times)
0 Members and 1 Guest are viewing this topic.
Offline James van Dalen

Senior Newbie

« Posted 2013-10-15 06: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:

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 07: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 07: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

(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.

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:

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.

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2013-10-15 07: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 Knight

Medals: 49

From rags to rags.

« Reply #4 - Posted 2013-10-15 07: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 07: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 07: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 Kernel

Medals: 95
Projects: 8
Exp: 5 years

Complex != complicated

« Reply #7 - Posted 2013-10-15 07: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 07:41:13 »

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:

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.

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
Offline James van Dalen

Senior Newbie

« Reply #9 - Posted 2013-10-15 07: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 07:47:28 »

Oh yeah.  On that WebGL demo...the thing is that defects are less likely to be noticeable when noise is used this 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 07:51:42 »

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

JGO Knight

Medals: 49

From rags to rags.

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

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

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 09:06:11 »

I've been attempting to motivate myself to do a write up on this kinda stuff (since the before the wiki 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 11: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 goofing around is at least if not more important.
Offline philfrei
« Reply #15 - Posted 2013-10-15 18: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.

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

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
Offline CodeHead

JGO Knight

Medals: 49

From rags to rags.

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

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.

Riven (18 views)
2015-07-03 11:22:16

deepthought (45 views)
2015-06-30 15:39:44

deepthought (49 views)
2015-06-30 15:39:09

deepthought (62 views)
2015-06-30 15:36:52

Za\'Anzabar (29 views)
2015-06-29 05:44:54

TritonDreyja (44 views)
2015-06-24 17:10:40

CopyableCougar4 (43 views)
2015-06-23 00:34:45

BurntPizza (46 views)
2015-06-21 20:36:46

cookiecompiler (88 views)
2015-06-11 15:42:53

cookiecompiler (51 views)
2015-06-11 15:41:14
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 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‑
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!