Vertical colour gradient

Started by mhaze, February 04, 2022, 08:42:11 AM

Previous topic - Next topic

mhaze

Is there a simple way of getting a vertical colour gradient according to height?

Tangled-Universe

Get altitude -> colour adjust
Black point = altitude at which gradient starts (black)
White point = altitude at which gradient ends (white)
For example: black = 0 and white = 1000 will create a 0-1 gradient from 0m to 1000m altitude.
The gradient will be linear as long as gamma is 1, but of course you can change this.

With clouds there's a small "catch" you need to be aware of.
There 'get altitude' will work in world-space, but 'get altitude in texture' will use the texture space of the cloud layer as long as "move textures with cloud" is enabled.
If it's disabled then they behave more or less the same.
The center of the cloud layer is at an altitude of 0m when using texture space, always.
When not using texture space then the center cloud's altitude is at the altitude set in the cloud layer's coordinates.
For example: cloud altitude = 1000m and cloud depth = 1000m and "move textures with cloud" is enabled.
Then if you use "get altitude in texture -> colour adjust" with -500 for black and 500 for white will create a gradient from the cloud base to the cloud top.
If "move texture with cloud" is disabled then the gradient will be interpreted in world-space, thus -500m below the surface to 500m above the surface (just touches cloud base altitude in this case).
To get a similar result to the first example you'd need to change the colour adjust values to 500 and 1500 for black and white respectively.

mhaze

Thanks, I'll see if I can make that work!

WAS

It might be easier to use functions. It is for me at least. Lot more straight forward.

For example:

Get Altitude -> Add Scalar (Positive scalars are negative altitudes, and negative scalars are positive altitudes) -> Divide Scalar (So you define exact fuzzy zones)

Get Altitude starts at world space 0 elevation. So you're just adding or subtracting to the altitude you want exactly. Pretty much the same thing the Surface Layers use. To have a mask that covers from negatives to positives, just use a complement scalar at the end.

Tangled-Universe

That's also a way of doing the same, but with more nodes.
To control fuzzy zone with my method the difference between the black and white value will be the fuzzy zone, which you can then also conveniently adjust using gamma.
I did notice though that the behavior of these nodes is slightly different when using surfaces.