Need help with clouds following terrain.

Started by Mohawk20, November 29, 2013, 12:05:22 PM

Previous topic - Next topic

Mohawk20

Hi guys,
I feel stupid, so I need your help...
I'm working on a little scene with a road trough a forest, going down a bit of a slope.
I wanted some whiffs of fog between the tees, but as the cloud goes further from the camera it's starting to create a straight plane, instead staying between the trees.
Now I know there is the altitude offset function, and I read Martins tutorial and checked the threads on this forum, but somehow I can't get it to work.

I attached the tgd file, for those of you who want to see what I did wrong (probably something simple).
So thanks in advance.
Howgh!

Upon Infinity

Functions like this can be a little bit tricky and downright frustrating.  A screenshot could have helped, but what you could try is either have a localized cloud layer that has enough height to cover the desired area, or you could layer multiple clouds layers forming a sort of "steps" to do the job. 

Mohawk20

I could use several cloud layers, but that would create a stepped effect, and I want it realisticly smooth.
And I want to learn how to make the clouds follow the terrain anyway, because it's useful in other projects too.
Howgh!

Dune

Try increasing the cloud depth 10x to 150m and decrease function multiplier by 10x to 10. Play with those settings. The initial cloud still needs to be quite high, then with the function multiplier and constant color (or PF with interesting variation) you squash that cloud.

Hetzen

#4
Dune is right with needing to increase the cloud depth. The offset function needs a depth that covers the range that a band of cloud can be moved up and down.

Your valley dips to -215m from 100m so your cloud depth needs to cover this range, or where you want your effect to be. You'll shrink the cloud layer depth back down to 10m with the depth modulator. So if you set your cloud altitude to 0 and set it's depth to 400, this should cover your scene (-200m to 200m in y).

If you want your cloud layer to be 10m you need to divide the 400m by 10 to get the fraction of the whole you need to modulate the cloud depth modulator. In this case your depth modulator needs to be 40th of your cloud depth, so the depth modulator input constant needs to be 1/40 or 0.025. The Dm works by accepting a fraction of 1 (1 is full range, 0.5 is half, etc), to pull the height towards where ever the centre is set (in the function tab of the cloud node), default is 0, which is the bottom of the cloud layer, 1 would pull the base towards it's top. Unplug anything going into your altitude offset on the cloud node, and set it's internal function multiplier back to 1

So now the cloud should render flat at the bottom of your range, in this case -200 to -190.

Next you will need to get a signal from your terrain height to offset the altitude. Your PF is using it's internal displacement function, so you'll need to convert this output to an altitude range, by adding a displacement to vector (functions/convert), then that into a length to scaler. This output should now tally with your terrain's altitude.

Plug that into an add scalar node with a constant scaler of 200 (use this number to tweak the cloud level). Then that into the offset function of the cloud layer. The logic goes, if the terrain is at -200 we add 200 to create no cloud offset when it's base in the depth range is already at -200. If the terrain is -100 the offset into the cloud node will now be 100 (-100 + 200 = 100), so 100 ontop of the cloud node's base depth which is -200, = -100 your terrain height.

The cloud should now follow the contours of your terrain.

Mohawk20

Whoa, there I was hoping it would be simple...
You are a true genius, I hope I can get it right with your help.

I'll try ASAP.
Howgh!

Mohawk20

#6
I set everything like you said, but I can't get it to work. The constant input of 0.025, is that colour or scalar?
Or could you possibly post the fixed tgd?


Got it!
I changed the Function Multiplier of the Altitude Offset Function from 100 to 0.95, and that did the trick. Now I just have to tweak the clouds appearance.
Thanks so much for your help!
Howgh!

Hetzen

You're welcome. I think I made it sound more complicated than it should be.

I'd put your multiplier back to 1. The offset constant 200 should do all the work of moving it up or down in meters.

201, raises the cloud layer 1 meter.
210, raises 10m.
190, lowers -10m.

You would be skewing this simplicity by saying it all worked at 95%.

This is just how this set up works with your scene.

The point is, the depth multiplier is used to create a band within your cloud depth, that you use meters to offset.

Displacement to vector is a really cool function to get a displacement value from any input terrain. Be it heightfield, PF or simple shape shaders etc. It will generate an xyz direction a surface has been displaced. This is a 3 dimensional value, so it wil record where your surface was to now. Length to scalar says by how far.

Matt

#8
Quote from: Hetzen on December 06, 2013, 05:10:26 PM
Displacement to vector is a really cool function to get a displacement value from any input terrain. Be it heightfield, PF or simple shape shaders etc. It will generate an xyz direction a surface has been displaced. This is a 3 dimensional value, so it wil record where your surface was to now. Length to scalar says by how far.

A note about Displacement shader to vector. If you take a Displacement shader to vector node and plug it into a function that expects a scalar (e.g. the cloud setup you're discussing here), it can catch you out if the displacement is negative. Negative displacement just means a vector that points downwards (or inwards), and whenever that's auto-converted to a scalar it will always give a positive value because it calculates the length/magnitude of the vector. Really what you need to do is get the Y component of the vector, or the dot product with the surface normal. You can do that with a couple of extra nodes, but if you're using TG3 there's a simpler way.

Terragen 3 has a new function called Displacement shader to scalar which gives you a the value you probably expect even when it's negative. Internally it does this by calculating the dot product of the vector and the surface normal. I would recommend that you always use Displacement shader to scalar, not Displacement shader to vector, unless you really want to know the actual vector of displacement.

http://planetside.co.uk/wiki/index.php?title=Displacement_Shader_to_Scalar

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Mohawk20

I'll try that Matt, see if the result is the same.

Hetzen, one last question: In your example render you had thin clouds. But following your instructions I get clouds as high as the trees. What value do I need to change to get thin whisps of cloud?
Howgh!

Hetzen

#10
Make the band of cloud thinner by decreasing the 0.025 value. If you want 1m clouds, 1m goes into a cloud depth of 400m 400 times, so 1/400=0.0025.

I don't think I did anything else to your scene. Although I did decrease quality settings to get a quicker render. Could be that.

Thanks for the clarafication Matt. Displacement to scalar it is. That scene must have had the camera some distance away from the origin to see -ve numbers in the y then, otherwise it shouldn't have worked. If it hadn't I would have tried multiplying the Displacement to Vector by (0,1,0) to strip out the Y like you suggested. I suppose a Y to Scalar from the DtV would work too, as the displacement is only in the y axis in this scene.

Mohawk20

Just so I understand this thing completely: the 0.025 constant, is that a constant colour function, a constant vector function, or a constant scalar function, or do all 3 have the same effect? Right now I'm using a constant colour.
Howgh!

Hetzen


Mohawk20

Quote from: Hetzen on December 07, 2013, 03:03:36 PM
Constant Scalar.

Which explains why I couldn't get my clouds thinner, the Constant Colour doesn't go below 0.1.
Thank you for all your help!
Howgh!

Matt

Quote from: Mohawk20 on December 08, 2013, 07:13:41 AM
Which explains why I couldn't get my clouds thinner, the Constant Colour doesn't go below 0.1.
Thank you for all your help!

Where was this happening? Constant Colour shouldn't have a limitation like that. You can type in any value, even negative values. Even if you use the colour picker, which rounds the values somewhat, the lowest non-zero value should be very close to 0.

Matt
Just because milk is white doesn't mean that clouds are made of milk.