## Sand (Desert, dry lake surface, cracked surface)

Started by Alkin, June 02, 2009, 10:53:15 AM

#### Hetzen

I need to tidy up my TGD, but after I do, I'll post it with some instructions on how and why I used what I did, with the proviso that anyone modding the network post their results back in this thread.

#### Alkin

Quote from: Hetzen on June 02, 2009, 09:47:37 PM
I spent a couple of hours playing with this, and here's where I got to using functions. I may spend a little more time with it. The trick with the ripples, is to to use Get Altitude to drive the Sine function, so the contours follow the landscape, and a Bias function allows you to give the ripples more of a steeper peak.

It looks very nice. Could you give more details on how to make something like that?

#### dandelO

Nice, Hetzen.
I'm clueless when it comes to most of the functions, no idea.

I'm going to carry on with fractals and see where I get to...

#### Alkin

BTW dandelO i am following your footsteps, but so far somewhat successful.

#### Hetzen

#19

As promised, I've attached a working TGD and pic of the node network, and I'll try and talk you through it.

I wanted to create ripples that followed the contours of the landscape, rather than all heading in one direction as you would get if you used just an X or Z value from a Get Position node as shown in the previous tutorial. What you have to remember, is that the Get nodes return the value at the point being calculated in the chain of commands. You'll notice that the ripples are applied after I had worked out some suitable settings for the basic dune shapes, because I wanted the function to look at where it was in relation to the height on the landscape.

A Get Altitude node is connected to an Add Scaler which is connected to a Perlin 3D Scaler to add some variation to the otherwise regimental concentricness you'd get with out it. (As described in the previous tutorial). This Add Scaler is then plugged into a Multiply Scaler before the Sin function.

A Sin function will take any value from -infinity to +infinity and always output a value from -1 to +1 as the input increments. It will do this in a curve shape that we all know from basic maths. The larger the the steps of value being fed into it, the faster it will output a curve from -1 to +1 back to -1. So with this in mind, the Multiply Scaler before the Sin Scaler acts as a frequency multiplier, ie the more I multiply the value of the input, the faster the oscilation from -1 to +1, resulting in more ripples per meter. OK? Still here?

So we now have an output of -1 to +1 as we go up and down the altitude of our landscape. What I wanted to do now is distort that sine wave with a Bias Scaler, which essentially looks at that curve and pinches or pulls the shape. Take a look in the node reference to see what I meen. But it only works on values between 0 and 1, so I now need to convert my -1 to +1 from the Sin Scaler to get my values between 0 and 1. To do this, I added 1 to (-1 to +1) to now give (0 to +2) and then divided this by 2 (or multply by 0.5) to give 0 to 1.

This is then connected into the displacment node, and the value of displacment inside that node I used was 0.3. Think of this as the amplitude, ie the height of the sine wave.

So there you go. Function nodes aren't really as daunting as you first think. There is a logic behind them, rather than some black art. Saying that, I've only recently just started playing around, and barely scratched at what can be done with them.

So have fun with this, and let me see what you come up with.

#### mhall

Hi Hetzen,

Very cool.

I was just wondering ... can you use the clamp 0 1 node to restrict your values to between 0 and 1?

I'm just a lurker (I'm a photographer by trade and, though I did buy Terragen with Animation, I don't use it because I know that, if I start rendering,  I'm not going to stop! So I get my fix by reading the forums and admiring the artwork), but I thought I had read that was what the clamp node was for.

Just thought I would mention it as it might simplify your node network a bit.

Or am I off on that one?

Regards,
Micheal

#### Hetzen

#21
Mhall, as far as I know, the Clamp 0 1 excludes anything below 0 and above 1, rather than compressing values into the range 0 to 1, could be wrong.

Sometimes I do wonder why I spend so much time in this program, when I know it would be far easier to just take a photograph or photoshop a series of images. But then I come up with cool ways of implementing this software in other stuff I do at work, where getting the right angle or changing the lighting or moving along a camera track would have a cost and resource implication.

#### mhall

Got it - so rather than gradually compressing the values as with the multiplier/divisor the clamp node would result in flat spots where a series of values all return 0 or 1 with a slope of changing values between them.

Makes sense.

I love photography - and made a conscious choice to leave computer graphics to concentrate on photography about 9 years ago - but I'm also itching to really dive back in to Terragen. I love what I see here on the boards and I spend a lot of time on the road driving -  through California, Nevada, New Mexico, Arizona, Wyoming, Colorado, Oregon and Washington this year. Though I see beautiful vistas that I would love to photograph, I most often find myself wondering how I would workout the scene in Terragen or how I would model the plants or hero rocks.

Regards,
Micheal

#### Hetzen

#23
No problems Micheal, I've borrowed enough off others here. I find myself looking at nature on the way into the office too, with TG in mind, clouds are great things to study with polarised glasses btw.

What will compress numerical values outside of math, is a colour adjust shader funnily enough, by moving the black and white points, a bit like levels in photoshop. TG treats black as 0 and white as 1, anything above and below that value can still be a colour, except you won't be able to see it, hence the clamp function if you need to visually control values.

#### mogn

Quote from: Hetzen on June 03, 2009, 05:54:48 PM
So we now have an output of -1 to +1 as we go up and down the altitude of our landscape. What I wanted to do now is distort that sine wave with a Bias Scaler, which essentially looks at that curve and pinches or pulls the shape. Take a look in the node reference to see what I meen. But it only works on values between 0 and 1, so I now need to convert my -1 to +1 from the Sin Scaler to get my values between 0 and 1. To do this, I added 1 to (-1 to +1) to now give (0 to +2) and then divided this by 2 (or multply by 0.5) to give 0 to 1.

The conversion between -1..1 can be done in another way (possible slower, but saves 1 node):

connect your input to the left input tab of a "mix scalar", connect a "constant scalar" value of 1 to the middle tab of the "mix scalar". Thats all, the output of the "mix scalar" if the function you want.

#### Hetzen

Thanks for that, but I'm still unclear how it works. The wording in the node reference doesn't seem to help either, it doesn't explain how it compresses values outside of 0 and 1.

#### domdib

Thanks for the TGD and the detailed explanation.

#### rcallicotte

Thanks for your work, Hetzen.  This is a great contribution to our community.
So this is Disney World.  Can we live here?