Procedural Terrain

Halloo unity community. I’m Ricardo and I model and code, both of which are still relatively new skills for me.

I’m bashing my head against the brick wall that is procedural terrain generation. I learned a lot through Lynda.com about c#, programming fundamentals, and unity scripting. Furthermore I’ve gone through the scripting tutorial videos on unity.

I’ve also continuously bludgeoned myself with procedural content and terrain generation tutorials and information for weeks and I can still bare make heads or tales of it. I even have code through Lynda.com that makes procedural voxel terrain and I still don’t get it.

I need people to help me bludgeon myself with knowledge so I can ask questions when I am confused, which is fairly often at this point.

I’m aware of what perlin noise is on a general level and I have at least one example of its implementation. I just recently heard the term marching cube, though I don’t really understand it. I keep hearing about things like triangle and edge lookup tables and whatnot, but I am just so lost, please help me get un-lost.

Oh, if it helps, I’m trying to specifically learn how to procedurally generate a mesh or iso-surface with with procedurally generated height values, include caves, and add procedurally pgenerated textures, placing environmental elements like trees and animals etc…

I’m hoping that in the process of learning I can deepen my understanding enough to develop new techniques and contribute to the field of procedural content generation, I’m just having a hard time understanding some basic concepts is all.

This may be worth your time:
http://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/introduction-to-heightmaps

We create random terrain using clouds in photoshop… but you may be able to use some sort of perlin noise to help this if you want to do it totally in code (Unity - Scripting API: Mathf.PerlinNoise).

Also, we’ve just posted this project on our site:

I will be promoting this from “lesson” status to full blown project today, and I’ll post that link in that thread…

1 Like

Danke, I was actually trying to do it all in code because I wanted to make it pseudo infinite, I guess I sorta left that part out.

Thank you, I wasn’t quite sure how splat maps worked but this definitely gave me some ideas. I was going to generate the height map, trees, everything all in code, but now that I think about it more deeply, I could probably just have some pre-built terrains that fit together like puzzle pieces and only use the code to spawn a terrain, despawn the previous terrain, and only apply a pseudo random or noise value to the chance of different types of terrain spawning in.

I’ve not looked very deeply into the Terrain api, but perhaps there is something you can do with it to create terrain on the fly and feed it into the terrain system…

This might be best posted somewhere else, as this forum is for talking about existing tutorials and teaching projects, rather than support.

Not sure which forum is the best… Probably “General Support”.

I’d also suggest hanging out on the IRC Chat channel (Info is in the “Community” tab) and eventually someone will pass through that knows something about terrains.

Ohhhh, sorry. New to the forums

No problem. We help out as much as possible, but when it really moves from the realm of me pointing you to exising tutorials to support, I’d suggest Answers, the Support Forum, or IRC.

Just to update you, I looked into more specific vocabulary and now I get how it works. It’s super complicated but at least it makes sense.

If you find any gems, please share!

http://paulbourke.net/geometry/polygonise/

This website was particularly useful as I didn’t understand a lot of the sample code I was looking at, but the link describes the concept and makes it possible for me to visualize what’s going on. The trick then to dynamically generating terrain is to use code to define eight vertices or corners of a cube and then to use perlin noise to throw in some random data and using edge and triangle lookup tables find out whether our theoretical perlin noise shape passes between or over the corners of this imaginary cube also known as a voxel.

If the perlin noise would pass between two vertices of a cube (if either existed as anything more than ideas and numbers at this point) then it is intersecting and edge, and by interpolating to isolate that point of intersection I can treat it as a vertex of a triangle and then finally create triangles from the vertices that we found by interpolating edge intersections.

It’s all very complicated, but basically it means that we make a bunch of imaginary cubes in code and then use perlin noise to make an imaginary blob. Then we use maths to find out where the blob and the cubes intersect and draw triangle meshes to represent those intersecting faces and viola, this produces height maps from values obtained by perlin noise and yet is a voxel procedural terrain which can be made pseudo infinite by despawning cubes from one edge and spawning them at the leading edge to create a sort of conveyer belt. Every time we spawn a new cube the code calculates those intersections and returns triangle meshes forming our terrain.