• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
spacekid434

Perlin noise and procedural generation

8 posts in this topic

I've recently been working on a 2d RPG adventure game in Java. I have world loading among other things and I want to use procedural generation for the landscape of the game world.

I have had no previous experience with procedural generation so this was quite a learning curve for me and I feel I have done fairly well. I finally managed to make a Perlin noise demo with help from this article [url="http://devmag.org.za/2009/04/25/perlin-noise/"]here[/url] and I'm fairly happy of the [url="http://dl.dropbox.com/u/21274231/games/noise.jar"]result[/url] (that demo uses a persistence of 1 and 8 octaves).

Here is the code for my Perlin noise. It's very fast to generate compared to some of the other algorithms I've tried. Im using a linear interpolate method because I don't notice the difference between a cos one except for the fact that linear is MUCH quicker...

[CODE]
double[][] genWhiteNoise(){
Random random = new Random(seed);
double[][] noise = new double[width][height];

for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){
noise[x][y] = random.nextDouble() % 1;
}
}

return noise;
}

double[][] generateSmoothNoise(double[][] baseNoise, int octave){
double[][] smoothNoise = new double[width][height];

int samplePeriod = 1 << octave;
double sampleFrequency = 1.0f / samplePeriod;

for(int x = 0; x < width; x++){
int sample_x0 = (x / samplePeriod) * samplePeriod;
int sample_x1 = (sample_x0 + samplePeriod) % width;
double horizontal_blend = (x - sample_x0) * sampleFrequency;

for(int y = 0; y < height; y++){
int sample_y0 = (y / samplePeriod) * samplePeriod;
int sample_y1 = (sample_y0 + samplePeriod) % height;
double vertical_blend = (y - sample_y0) * sampleFrequency;

double top = interpolate(baseNoise[sample_x0][sample_y0], baseNoise[sample_x1][sample_y0], horizontal_blend);

double bottom = interpolate(baseNoise[sample_x0][sample_y1], baseNoise[sample_x1][sample_y1], horizontal_blend);

smoothNoise[x][y] = interpolate(top, bottom, vertical_blend);
}
}

return smoothNoise;
}

double[][] perlinNoise(double[][] baseNoise, int octaveCount){
double[][][] smoothNoise = new double[octaveCount][][];

for(int i = 0; i < octaveCount; i++){
smoothNoise[i] = generateSmoothNoise(baseNoise, i);
}

double[][] perlinNoise = new double[width][height];
double amplitude = 1.0;
double totalAmplitude = 0.0d;

for(int octave = octaveCount - 1; octave >= 0; octave--){
amplitude *= persistance;
totalAmplitude += amplitude;

for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){
perlinNoise[x][y] += smoothNoise[octave][x][y] * amplitude;
}
}
}

for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){
perlinNoise[x][y] /= totalAmplitude;
}
}

return perlinNoise;
}
[/CODE]

First off, can someone please tell me if the noise I have generated if suitable for random world generation or if it's not, can they give me some tips and/or links to good examples.

and second, can someone please tell me a good place to start for turning that Perlin noise into a game world. I am using a tile based system and i plan on having mountains, sand dunes, forests and cities (they wont be randomly generated but they will have a random location in the world based on some placement parameters).

Any help would be very much appreciated.
0

Share this post


Link to post
Share on other sites
I'm not sure it uses perlin noise specifically, but is this similar to what you're after?

[url="http://members.gamedev.net/vertexnormal/tutorial_randlev1.html"]http://members.gamedev.net/vertexnormal/tutorial_randlev1.html[/url]

You could quantise the noise values into discrete bands, and assign each band a tileset - grass, rock, snow, lava. You could also need edge tiles, depending on the look you're going for.

Can you show an image of the noise you're generating?
1

Share this post


Link to post
Share on other sites
Thanks, I'll have a look at that website when I'm back home.

I did put a link to my perlin demo in the post but here's the image anyway:

[img]http://dl.dropbox.com/u/21274231/Untitled.png[/img]

Thanks
0

Share this post


Link to post
Share on other sites
Procedural terrain generation is an interesting topic, I'm working on a 2D MMORTS and I used the Square-Diamond Algorithm for terrain creation, I am quite happy with the result. This is a screenshot of the terrain generated for my game.

[img]http://i44.tinypic.com/2re639y.gif[/img]

This is a great tutorial to understand the algorithm wich is easy to implement once you understand how it works
http://gameprogrammer.com/fractal.html
0

Share this post


Link to post
Share on other sites
i used perlin noise and ridged multi-fractal noise in mine to build biome, temp, wind, and rainfall maps. The library i used was Libnoise [url="http://libnoise.sourceforge.net"]http://libnoise.sourceforge.net[/url]

Here is an early prototype:

[img]http://img.photobucket.com/albums/v716/zediker/world_latest.jpg[/img]
0

Share this post


Link to post
Share on other sites
How you translate your noise functions to a game world depends on a great many factors. Does a cell or unit in the noise map translate to a single tile in the world, or does it translate to a sub-map or region? What sorts of characteristics can a tile or region have? Typically, you're going to use more than just a single layer of noise. As an example, in [url="http://www.gamedev.net/blog/33/entry-2249282-hooking-into-the-tree-to-build-a-map/"]this[/url] journal post, I use several layers of noise and turbulence denoting the shape of an island, elevation and roughness of terrain, aridity, etc... and translate units into tiles in a simple tile map:

[img]http://uploads.gamedev.net/blogs/monthly_01_2011/blogentry-47547-0-72940200-1296083423_thumb.jpg[/img]

Translated into tiles:

[img]http://uploads.gamedev.net/blogs/monthly_01_2011/blogentry-47547-0-43024200-1296084301_thumb.jpg[/img]

This is a very simple example. You can get more complex depending on your needs. All sorts of information can be simulated using noise maps: elevation, placement of regions, density of vegetation, etc... Add a few simulated modeling processes (erosion, weather patterns) and you can come up with some pretty complex worlds.
0

Share this post


Link to post
Share on other sites
Oooh, me too me too me too [url="http://www.progsch.net/applets/proto.html"]Island Applet[/url]. it's essentially a 2d noise heightmap that gets modulated with another noise function to create regions of different "steepness".

Just get a noise function/generator some way to output images based on it and start playing. I starts getting intuitive pretty quick.
0

Share this post


Link to post
Share on other sites
I'd also suggest looking into Ken's followup version: "Simplex Noise" as it runs considerably faster, fixes a couple of visible pattern issues in the original and is much easier overall. From there, another source of information would be the book from the masters themselves: [url="http://www.amazon.com/Texturing-Modeling-Third-Procedural-Approach/dp/1558608486/ref=sr_1_1?ie=UTF8&qid=1327285046&sr=8-1"]http://www.amazon.com/Texturing-Modeling-Third-Procedural-Approach/dp/1558608486/ref=sr_1_1?ie=UTF8&qid=1327285046&sr=8-1[/url] It's an older book but given Perlin, Musgrave and Worley talk about how they use noise and variations, some of the helper functions listed in Worley's section I believe (bias/gain being two of my favorites) are excellent starting points for getting a better understanding of how to fiddle with the output of noise functions.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0