Altitude offset function

Started by Hannes, May 13, 2012, 03:49:45 AM

Previous topic - Next topic

Hannes

First of all: yes, I read Martin's great tutorial ;). Thank you!!
In the tutorial it was recommended to use an image shader. So if you use a localised cloud layer it's not possible to use the power fractal you used for the displacement of the terrain as an altitude offset function to create clouds that follow the terrain?
It takes a lot of time to create a greyscale image first out of an exported terrain and to convert all the stuff with other programs and so on.
Martin wrote that "it would be really slow to compute the terrain's altitude straight from your network and use that as input for your altitude offset."
So is it only not recommended or just impossible to use a PF as input?

Hetzen

If you create a heightfield from your displaced terrain, and use the colour by altitude, you can create a gradient to drive the offset function.

Hannes

Good to know! Thank you, I'll give it a try.

dandelO

I don't think it has ever been officially recommended not to use fractals for cloud function inputs, I always do. What would be the point in cloud functions if they couldn't accept a fractal, which clouds are basically made of in TG?
Things get a bit boring if you can only use cloud functions to move/shift layers by a constant, flat amount all over, or similarly, by a fixed image map.

Here's a post from Matt regarding this, get those fractals plugged in there, Hannes! ;) http://www.planetside.co.uk/forums/index.php?topic=12622.msg125712#msg125712

Hannes

OK, no matter what I try, it only works with image map shaders.
Let's say I create a terrain using a power fractal. Then I add a cloud layer that covers the terrain vertically up to the peaks. I use the power fractal for the altitude offset function and enter the same value like the displacement amplitude. Nothing happens. Even with different values it looks like there's no offset at all. The clouds always look the same.

It seems that creating clouds following the terrain isn't the easiest thing in TG. Or it's me... :(

dandelO

#5
First, to get clouds to follow terrain, I'd make sure the terrain shader is applying colour(a default 'fractal terrain', added from the terrain tab won't), use the colour of the terrain shader for the depth modulator and then positively offset it by pure white(like Martin describes in the tut' you read) by the amount of metres you want the cloud layer to be above the terrain. To get a better visual feedback of the cloud while building it, unplug the density fractal, then your cloud will be built from depth function alone, which you'll later break up with the density fractal.

Make sure there's enough room left within the final depth of the cloud layer to offset it within, otherwise, you'll end up with a cutoff where the cloud top is. To make the cloud layer takes the same shape as the terrain, use a depth modulator value of '0' so you are building the cloud depth from the bottom upwards. A depth value of '0.5' will build out the cloud depth from the centre of the layer outwards, a depth value of '1' will build it from top to bottom(like the inverse of the terrain.

Hannes

Ah, I see. Thank you, dandelO. Something to play with. I hope it will work. I'll keep you informed.

Hannes

Yep, seems to be working!!! Thank youuuuu!! ;) ;) ;)

mhaze

Still struggling with this one.  I get some change by disabling displacement on the PF and using a displacement node instead.  But I don't seem to get the effect I want. I guess it's going to take some hours of experiment.  Any more tips?

Matt

In 2.4 you can convert any displacement shader directly into a function, using "Displacement shader to vector" (in the Function/Convert menu). If you want to restrict it to only Y displacement you  can do this with Function/Convert/Y to scalar, but in typical cases where the displacement is along the normal you can just use the Displacement shader to vector node directly. That will work nicely as the cloud's altitude offset function.

Bear in mind that the cloud can never exist outside the minimum and maximum altitudes, determined by cloud altitude +/- cloud depth divided by 2. Altitude offsets and depth modulators change the shape of the cloud but can only produce cloud within this range of altitudes.

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

Dune

QuoteIn 2.4 you can convert any displacement shader directly into a function
So, can you also use this to convert the displacement of a PF into a gray scale mask, which should then give the heights in whites? That would be very handy. I'll do some testing...

mhaze


cyphyr

Quote from: Dune on May 20, 2012, 02:46:49 AM
QuoteIn 2.4 you can convert any displacement shader directly into a function
So, can you also use this to convert the displacement of a PF into a gray scale mask, which should then give the heights in whites? That would be very handy. I'll do some testing...
Now that would be useful ...
Richard
www.richardfraservfx.com
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

Matt

#13
Yes. Once you have a function of any kind, it can be plugged in anywhere that expects a colour shader (including blend shader inputs). To ensure that it's greyscale, run it through "colour to greyscale colour", or grab a specific axis of displacement by using "Y to scalar" - that will also be greyscale.

Bear in mind that colours and masks usually go from 0 to 1, whereas the displacement values will be in meters so could potentially be much higher or lower.
Just because milk is white doesn't mean that clouds are made of milk.

Dune

#14
YES! Thanks, Matt.  :D :D

Although..... it doesn't work exactly as I would have expected.... or am I doing/thinking something extremely stupid here?

I was hoping to find an easier way to restrict foam to coasts for instance...