0
\$\begingroup\$

I'm trying to create a voxel engine that uses marching cubes to create smoothed terrain. I have most of it implemented, but I'm struggling with how I should create a noise function in three dimensions. I have a 2D Perlin noise generator implemented (or I could use the Unity built-in one, I guess). What can I use for 3D?

I'm also interested in the noise function being usable in chunks with uniform output. That way, with one seed, I could create a level in parts that would still all work properly.

\$\endgroup\$
  • \$\begingroup\$ The 2D perlin noise can apply to 3 dimensions - the location on the image corresponds to a location in the world and the color value corresponds to a heightmap. Is this not what you want? \$\endgroup\$ – DoubleDouble Jan 22 '16 at 20:04
  • \$\begingroup\$ I have used my perlin noise generator for a heightmap before and it works fine, but I want to create voxel terrain which can actually have more than one y value mapped to every (x,z) coordinate. This requires 3D perlin noise from everything I've read. Check out marching cubes as an example. \$\endgroup\$ – guitar80 Jan 22 '16 at 20:05
  • \$\begingroup\$ Ah, I understand \$\endgroup\$ – DoubleDouble Jan 22 '16 at 20:09
  • \$\begingroup\$ Exactly! I just don't know how to create that 3D function. And preferably (i think it should be) it could be chunkable so I can "somewhat eternally" load in new meshes as the player moves. \$\endgroup\$ – guitar80 Jan 22 '16 at 20:11
  • \$\begingroup\$ flafla2.github.io/2014/08/09/perlinnoise.html explains perlin noise and provides interesting links for further reading. \$\endgroup\$ – Exilyth Feb 19 '16 at 18:37
-2
\$\begingroup\$

Thanks to some of the above comments I did find my answer. I forgot to post my answer, but I thought I would go ahead and add it for anyone who is curious. I recommend looking at the original algorithm and also the above mentioned link to explain the general idea.

I chose to use three-dimensional Perlin Noise (by Ken Perlin originally). This is a smooth generated noise that can be visualized much like sin waves in 3D. The values vary slowly and the algorithm uses a seed to generate a permutation table. This table and an (X,Y,Z) coordinate is used to determine the noise value at a particular location. The pattern does repeat eventually, but seems to work well for a voxel engine. Since the computation is expensive, I recommend doing the computation on the GPU or limiting its use.

\$\endgroup\$
  • \$\begingroup\$ Well I can try to, but I only have a limited understanding of how exactly perlin noise works, so I thought it might do people a disservice. My original question was what algorithm to use, so I will edit and mention Perlin Noise specifically, but explaining it (I think) might hurt the helpfulness. \$\endgroup\$ – guitar80 Apr 22 '16 at 19:16
  • \$\begingroup\$ No, explaining it makes it better; without an explaination this is basically a link-only answer (and thus deleteable). The aspect of your question that's just asking for a list of algorithms or links to tutorial -- those aren't on-topic and should be edited out of your question (as I've done). You don't have to explain everything, you just have to explain enough that the answer could stand on its own as a response to implementing noise in 3D for future visitors without having to follow the link. \$\endgroup\$ – user1430 Apr 22 '16 at 19:24
  • \$\begingroup\$ I was trying to help other people aim for the right answer. If someone else wants to explain perlin noise in detail they are more than welcome to, I just used the code at the link. So I'm not sure what more explaining there is to do. If you'd like I'll delete the comment and you can answer. My apologies if it isn't helpful, it seemed to work for my problem. \$\endgroup\$ – guitar80 Apr 22 '16 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.