• 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
ReqPro

Perlin Noise seamless chunks problem

2 posts in this topic

Hey everyone!

First of all, hope this is in the right place [img]http://public.gamedev.net//public/style_emoticons/default/ph34r.png[/img]

I've been fighting with this for a long time now, and I think I've come to the point where I've stared myself blind on the problem.
Here's hoping one of you can help me [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Here's the thing; I've made a minecraft-type world, divided into chunks of each 32x32x128 blocks. I've got a perlin noise generator creating the heightmaps so that they'd (hopefully) be seamless.
I've come close, but there are some minor issues I just can't iron out.

As a picture says a thousand words, I'll attach a screenshot where I've highlighted the seams with a red line to highlight my problem.

[img]http://s8.postimage.org/rhlc2pnet/fail.jpg[/img]

Now as you can see in the image above, there are some quite steep (and not very seamless) seams...
I'm completely at a loss as to how I'm going to remedy this.

Any pointers?

Thanks in advance,
Req

Edit:
Whoops, might be an idea if I included the code [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img]

Function call to generate and store noise:
[source lang="csharp"]
private void AddPerlinNoise(float f, float o)
{
for (int i = 0; i < Width; ++i)
{
for (int j = 0; j < Height; ++j)
{
Heights[i, j] += o + PerlinNoiseGenerator.Noise(f * (i + Index.X * Width) / (float)Width, f * (j + Index.Z * Height) / (float)Height, 0);
}
}
}
[/source]
PerlinNoise class functions:
[source lang="csharp"]
public static float Noise(float x, float y, float z)
{
int ix = (int)Math.Floor(x);
float fx0 = x - ix;
float fx1 = fx0 - 1;
float wx = Smooth(fx0);
int iy = (int)Math.Floor(y);
float fy0 = y - iy;
float fy1 = fy0 - 1;
float wy = Smooth(fy0);
int iz = (int)Math.Floor(z);
float fz0 = z - iz;
float fz1 = fz0 - 1;
float wz = Smooth(fz0);
float vx0 = Lattice(ix, iy, iz, fx0, fy0, fz0);
float vx1 = Lattice(ix + 1, iy, iz, fx1, fy0, fz0);
float vy0 = Lerp(wx, vx0, vx1);
vx0 = Lattice(ix, iy + 1, iz, fx0, fy1, fz0);
vx1 = Lattice(ix + 1, iy + 1, iz, fx1, fy1, fz0);
float vy1 = Lerp(wx, vx0, vx1);
float vz0 = Lerp(wy, vy0, vy1);
vx0 = Lattice(ix, iy, iz + 1, fx0, fy0, fz1);
vx1 = Lattice(ix + 1, iy, iz + 1, fx1, fy0, fz1);
vy0 = Lerp(wx, vx0, vx1);
vx0 = Lattice(ix, iy + 1, iz + 1, fx0, fy1, fz1);
vx1 = Lattice(ix + 1, iy + 1, iz + 1, fx1, fy1, fz1);
vy1 = Lerp(wx, vx0, vx1);
float vz1 = Lerp(wy, vy0, vy1);
return Lerp(wz, vz0, vz1);
}

private static float Lattice(int ix, int iy, int iz, float fx, float fy, float fz)
{
int index = Index(ix, iy, iz);
int g = index * 3;
return Gradients[g] * fx + Gradients[g + 1] * fy + Gradients[g + 2] * fz;
}

private static float Lerp(float t, float value0, float value1)
{
return value0 + t * (value1 - value0);
}

private static float Smooth(float x)
{
return x * x * (3 - 2 * x);
}
[/source] Edited by ReqPro
0

Share this post


Link to post
Share on other sites
Hi, I'm not entirely sure I understand your approach. I believe you're generating a heightmap based on a 2D slice of a 3D Perlin noise function. Is that correct? I gather that f is your frequency, and you call AddPerlinNoise once for each octave. I believe that you're meant to scale the contribution down by the frequency so it looks less spiky. I don't know what your float o is for, I suspect that may be the problem. if you pass a different value of o in for each block there would be inconsistencies. Given that your problem is between blocks, perhaps you need to show us the code for looping through blocks.
0

Share this post


Link to post
Share on other sites
[quote name='jefferytitan' timestamp='1345867056' post='4973184']
Hi, I'm not entirely sure I understand your approach. I believe you're generating a heightmap based on a 2D slice of a 3D Perlin noise function. Is that correct? I gather that f is your frequency, and you call AddPerlinNoise once for each octave. I believe that you're meant to scale the contribution down by the frequency so it looks less spiky. I don't know what your float o is for, I suspect that may be the problem. if you pass a different value of o in for each block there would be inconsistencies. Given that your problem is between blocks, perhaps you need to show us the code for looping through blocks.
[/quote]

Hi Jeffery,

thanks for your response. You're right, I haven't provided the necessary information to give you guys the best chance of providing a solution.
I am indeed generating 2D heightmaps off of a 3D PerlinNoise function.
F is my frequency, o is an offset that is added to the result of the function as it generated slices of terrain with zero height. As I'm using it now, it has an offset of 0.25f.
I actually only run the noise function once per coordinate set as it is right now. I later on then add perturbation, erosion and smoothing. Wait a second....

I found the solution myself though, right now as I'm writing this - you gave me a lightbulb moment....
my erosion passes screwed up the seams! It's so obvious now... Since the erosion passes are performed on each chunk individually, they can't be truly seamless!

Thanks Jeffery for leading me on the right path - I hate when I sit with a problem so long that I just go completely blind to the obvious! :)
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