Planetside Software Forums

General => Terragen Discussion => Topic started by: ProjectX on April 05, 2007, 02:10:03 PM

Title: Procedural Canyons (hurrah!)
Post by: ProjectX on April 05, 2007, 02:10:03 PM
I've worked out procedural canyons for you all (don't know if this has already been done or not). It's so unbelievably simple I won't post it as a clip file, I'll tell you how to do it.

Ok, make a fractal terrain (relatively flat, but with some small variation), this is going to be the variation for your canyon plateaus and also floors.

Now, in the terrain node editor, create a displacement shader. Plug the terrain into the input of the displacement shader, and plug the output of the displacement into the compute terrain node.

Nothing happened? Good.

Now, in the node editor, create another fractal, but do not connect it to anything. To begin with, don't mess around with the settings much, (i'm not actually sure if this helps or not, but I think changing the displacement amplitude sets the canyon vertical noisiness, along with feature scale being lateral noisiness)

No add a "get altitude" node and connect the newly created fractal to it. Add a "Y to scalar" function onto the end of that. What this does is converts the altitude of the terrain we've generated into a scalar value. This does have the downside of meaning that you have to do your funky lateral displacement tricks AFTER the canyon has been made.

Now, we're going to add a "multiply scalar" node, and a constant scalar node. Hook up the Y to Scalar into the multiply scalar input1, and the constant into input 2. You can set the constant to whatever you like, the higher the value, the sharper the canyon walls will be, whereas with lower values you'll end up with shallower slopes, and greater slope variation. I used 100 originally, and that gave very straight vertical walls, in the render below I used 10.

So now we have the scalar values for the altitude of our steep-walled terrain, what we're now going to do is clamp them, so that they don't go higher than a certain value (our plateaus) or lower than another value (our troughs). Add a clamp scalar function and hook the multiply scalar into the input, and two new constant scalars to the minimum and maximum handles. Set the minimum to the height of the floor, and the maximum to the height of the plateau (in meters). If the plateaus aren't high enough, then you can either increase the displacement multiplier in the displacement shader, or increase the scalar multiplyer.

Plug the clamp scalar into the function handle of the displacement multiplier, tweak and render.

Enjoy!

EDIT: One thing I've discovered while playing this is that if you adjust the multiplier, you have to adjust the clamp ranges. This is prossibly because the scalar range of the altitude is given between 0 and x. If we were to add nodes that subtract half of x and then multiplies, the down-ness would be multiplied along with the up-ness. So if your terrain goes flat again after tweaking (or before), just tweak the clamp settings - a good start is min: 0 and max: 1000, and move on from there.

I could of course be making no sense, and if so it is because I need sleep. Have fun.
Title: Re: Procedural Canyons (hurrah!)
Post by: child@play on April 05, 2007, 02:36:58 PM
wow, very well thought out and explained. thanks a lot, this will be useful  :)
Title: Re: Procedural Canyons (hurrah!)
Post by: rcallicotte on April 05, 2007, 03:08:20 PM
Brilliant.  Thanks.  I'm putting this in my notes.  LOL.  Cooool.   8)
Title: Re: Procedural Canyons (hurrah!)
Post by: nvseal on April 05, 2007, 03:40:13 PM
Nice work, I've been wondering how to do this forever.  I'm going to have to try this out later.  8)
Title: Re: Procedural Canyons (hurrah!)
Post by: Harvey Birdman on April 05, 2007, 04:19:01 PM
Really - that's pretty sophisticated use of the node network. Or at least it seems so to a raw noob like me.

;)
Title: Re: Procedural Canyons (hurrah!)
Post by: Will on April 05, 2007, 05:36:41 PM
Neat, thanks man! I count get it to work though maybe I'm doing somthing wrong.

Regards,

Will
Title: Re: Procedural Canyons (hurrah!)
Post by: Will on April 05, 2007, 05:46:40 PM
Nevermind I fixed it. For those who are having any problums try ramping up the displacment of your first fractal.

Regards,

Will
Title: Re: Procedural Canyons (hurrah!)
Post by: Harvey Birdman on April 05, 2007, 06:00:18 PM
Quotetry raping up the displacment of your first fractal


Ummm.... you know, the wife already thinks I'm spending too much time with this. She starts hearing talk of raping the displacement and she's going to stop me from hanging out here.

;D
Title: Re: Procedural Canyons (hurrah!)
Post by: Will on April 05, 2007, 06:05:39 PM
whoops, thanks for the heads up   :-[ fixed

regards,

Will
Title: Re: Procedural Canyons (hurrah!)
Post by: Harvey Birdman on April 05, 2007, 06:21:01 PM
Yes, but I have immortalized it.

:D
Title: Re: Procedural Canyons (hurrah!)
Post by: Will on April 05, 2007, 06:23:14 PM
Yea I deserve it though for not checking my spelling.  ;)

Regards,

Will
Title: Re: Procedural Canyons (hurrah!)
Post by: rcallicotte on April 05, 2007, 06:51:23 PM
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHA.

:D

That was hilarious!  You guys are a hoot.
Title: Re: Procedural Canyons (hurrah!)
Post by: RealUser on April 06, 2007, 06:35:50 AM
Thanks dude man!  ;D
Title: Re: Procedural Canyons (hurrah!)
Post by: edlo on April 06, 2007, 11:05:09 AM
Very nice investigation and results...now that is much better than dropping the clip or world file, good job ! ;D
Title: Re: Procedural Canyons (hurrah!)
Post by: neon22 on April 07, 2007, 05:14:03 AM
Nevertheless :-)

and it doesn't seem to matter if you have anything on input to the get altitude.
I suspect this node doesn't do anything with its input
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 08, 2007, 09:41:21 AM
I noticed that too, although mathematically there's no way it could work without the fractal on the get altitude (that's what controls where the canyons appear - there are canyons where there are valleys in the fractal - or at leat, that's what should happen). perhaps a more experienced node artist will be able to help (after all, I only really decided to do this after I read the terrain from functions tutorial on the wiki - I was a complete novice beforehand).
Title: Re: Procedural Canyons (hurrah!)
Post by: 3DGuy on April 08, 2007, 12:49:09 PM
One quick way I can create canyons is by just slapping on a distribution node, limiting the altitude and use the displace offset to move sections below or above a certain height up or down. That way use use the valleys in the original fractal as a base for the canyons. Like so:

Title: Re: Procedural Canyons (hurrah!)
Post by: rcallicotte on April 08, 2007, 01:25:23 PM
3DGuy, this looks good.  Thanks.
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 13, 2007, 11:19:51 AM
good idea 3dguy! The only downside I can see is that you can't plateau the tops.

I have noticed something odd with my canyon setup.

Counter-logically the get altitude gets the altitude on the input of the displacement shader and not the input of the get altitude shader.

This means that if you want a different pattern of canyons then you'll need to change the seed of the input terrain.

How odd.
Title: Re: Procedural Canyons (hurrah!)
Post by: dhavalmistry on April 13, 2007, 11:41:02 AM
and what happens when you disable that input power fractal shader....
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 13, 2007, 11:45:45 AM
The input of the get altitude shader? nothing. Therefore it is redundant.
Title: Re: Procedural Canyons (hurrah!)
Post by: 3DGuy on April 13, 2007, 12:07:17 PM
Quote from: ProjectX on April 13, 2007, 11:19:51 AM
good idea 3dguy! The only downside I can see is that you can't plateau the tops.

For flat tops you'll have to start with a smaller initial displacement amplitude.
example attached...
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 13, 2007, 12:50:25 PM
I see, that's clever, good thinking!
Title: Re: Procedural Canyons (hurrah!)
Post by: dhavalmistry on April 13, 2007, 02:33:47 PM
Quote from: ProjectX on April 13, 2007, 11:45:45 AM
The input of the get altitude shader? nothing. Therefore it is redundant.

no the actual shader...the one that connects to displacement shader...I know this should change the whole displacement...but try it....and then maybe you can go from there
Title: Re: Procedural Canyons (hurrah!)
Post by: Tsukiyono on April 22, 2007, 02:27:46 AM
ProjectX... what did your nodes look like once you completed the example?

Not sure if I got mine set up right as I set my one scaler to 100, and I dont have straight walls... ???
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 22, 2007, 07:22:10 AM
Uploaded a tgc for you.
Title: Re: Procedural Canyons (hurrah!)
Post by: Tsukiyono on April 22, 2007, 05:49:48 PM
Thanks much :)

Going to check it out :D
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on April 23, 2007, 03:52:12 AM
I put it in as one shader for you, (which is actually a renamed displacement shader) view the internal workings if you want to know how it all fits together. Plug a standard terrain with displacement around 1000 into it's input and plug the output into the compute normal.
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on July 24, 2007, 12:58:20 PM
I've worked it out, I was using the wrong node for getting the high points from the fractal, so it was effectively doing nothing. Thanks go to Volker for a massive help there!

Ok, here's what the nodes do:

Canyon Fractal: This fractal determines the shape of the canyons, you can modify the settings to change the overall shape. A noteable setting is the colour contrast and colour roughness settings, these determine the slope of the canyon walls and the degree to which the canyon wall is broken up.

Luminance to scalar: This is the function I was missing, it takes the degree of whiteness of the greyscale fractal and maps it to a scalar between 0 and 1. if we were to multiply this scalar now the white bits would get whiter, and so will the dark bits. The only bits that would not get lighter would be those that are absolute 0, so we have to manipulate the values a bit.

X2: This node multiplies the scalar by 2, so the range is between 0 and 2.

-1: This node subtracts 1 from the scalar, so the range is now between -1 and 1. When we multiply now, the darker bits get darker, and the white bits get whiter.

X50: This node multiplies the scalar by 50. This means that if we were to take a section of the scalar (say between 0 and -20) it would be a vertical wall. You can play with this to change the sheerness of the canyon walls.

Clamp -20,0: This node clamps the scalar between the values of -20 and 0. Think of this as being a canyon 20 meters high with valleys at an altitude of -20. Changing this value changes the height of the walls and the range of fractal detail captured. If you increase the displacement magnitude and decrease the sample range, your canyon walls will be shearer.

Attached below is the new shader. Plug it in on the end of your terrain, (you can also swap the internal fractal for your terrain fractal to have canyons only in the lowlands).

If you have any problems post here, and i'll see what I can do.

Edit> Added a quick render for you.
Title: Re: Procedural Canyons (hurrah!)
Post by: old_blaggard on July 24, 2007, 02:04:06 PM
Interesting result.  Looks like I'll be downloading the new version ;).
Title: Re: Procedural Canyons (hurrah!)
Post by: Volker Harun on July 24, 2007, 02:26:32 PM
I like it - the next step would be to make very narrow canyons ,-)
Title: Re: Procedural Canyons (hurrah!)
Post by: rcallicotte on July 24, 2007, 02:49:29 PM
Thanks for this explanation.  I'm struggling to understand concepts that you take for granted are clear and it isn't anything you're doing wrong; I'm in need of some real schooling.   ;D

Thanks for the TGC as well.  Very generous.
Title: Re: Procedural Canyons (hurrah!)
Post by: ProjectX on July 25, 2007, 07:22:28 AM
Quote from: Volker Harun on July 24, 2007, 02:26:32 PM
I like it - the next step would be to make very narrow canyons ,-)

To do that, you'd need to fiddle with the colour offset so that the majority of the fractal was white, probably using very few octaves of perlin ridges to preserve the canyon's length. otherwise you'd get a lot of very small canyons, more like massive pot holes really. I'll see what I can do.
Title: Re: Procedural Canyons (hurrah!)
Post by: Volker Harun on July 25, 2007, 07:56:26 AM
You got a PM ,-)
Title: Re: Procedural Canyons (hurrah!)
Post by: rcallicotte on July 25, 2007, 08:39:27 AM
Setting the Canyon Fractal's X and Z stretches to .25 narrows the canyons.  I also increased Y stretch to 5 and this looked pretty good.
Title: Re: Procedural Canyons (hurrah!)
Post by: Gothic on November 08, 2007, 11:03:01 AM
Oh my God... I love you two, 3DGuy and ProjectX. :-* Although I prefer 3DGuy's plateaus better; they're more suited to my needs. ;D

I've been trying for ages to achieve this effect... thanks for the aid guys!