Separating color from displacement

Started by uuderzo, June 19, 2020, 11:18:55 am

Previous topic - Next topic


I see that there are already other threads talking about shore foam and so on, but after reading some of them many times i came to the conclusion that i don't understand anything of Terragen :D

I mean... after the compute terrain, i added a surface shader (A) with white color, maximum altitude 0 and minimum altitude -50. If i use only this shader without water added to the project, i correctly see that the terrain is colored as expected. Say white at altitude 0 degrading to black at altitude -50. Elsewhere black. Fine.

But now i want to use this shader to drive another surface shader (B) in cascade of the water shader, then plug the result into a lake object. The purpose of (B) should be to paint white on the shore masking accordingly to (A) color.
What i get instead is that the lake gets displaced to follow the terrain, because it inherits the displacement coming out of the shader (A).

Moreover, the shader (B) doesn't appear to be driven by (A).
So, in the end, i get the water displaced and not affected by (B). Exactly the opposite of what i'm after.

Any clue? Pliz?


I threw together a quick file for you. I haven't tested further how to alter the very tiny white stripe, but at least it seems to work without altitude constraints. The key is to convert the displacement to scalar, I guess.
(OMG, I explained something about blue nodes!!!! ;) ;) ;) ;D )


Looks like converting the displacement to a scalar value leads the shader not to correctly obey the altitude constraints, leading to a bad color. I can notice in your example that the white shore is visible mostly in preview, if you render it becomes so thin to be barely visible.
There must be some way to strip the displacement AFTER the shader without losing what has been produced upwards... looks like Terragen scans the graph from the planet up to the terrain so before it reaches the shader it traverses the displacement to scalar conversion and it remembers it must lose the displacement info after this node.


I did some more testing and used a copy of the power fractal that creates the displacement to feed the "Displacement shader to scalar" node. I altered it a bit and added another power fractal. The white area is quite rough, but broken up by some foam texture (image or procedural) it might look OK.


I think i got it. I examined your latest example and did some little tweaks. Instead of cloning all the terrain generation node structure, i added a vector displacement node, converted into scalar as you suggested and then divided by a scalar to be able to modulate the value. Without the scalar division there will no digradation and the result would be less realistic. So, by acting on the displacement vector and the scalar divisor i can size the foam more or less as desired.

Then i plugged the result into the secondary water shader and it produces something i think is nice, as a starting point.

I'm still puzzled how to achieve the same effect leveraging a surface shader color controlled by altitude constraint, but i start guessing that Terragen won't allow this approach.

Anyway thank you so much for driving me in the right direction! You deserve a beer! ;)

Cheers! Umberto


That looks fantastic. I'll dive into your file asap!
A beer sounds good! ;)


Interesting. You can also just use a colour adjust on the displacement to scalar, and use the WP and BP. This also allows you to adjust falloff more visually with just the one shader and BP/WP values.

You method however has some benefits for steeper terrain, I think. As you can modulate it.


The color correction node, what an elegant solution! Also working on gamma allows more freedom.
Wonderful, thank you!

Terragen has many hidden tips, but it's good because it won't came with pre-cooked solutions. Alle the images are result of very personal study and discovery.



Quote from: uuderzo on June 19, 2020, 02:48:09 pmThe color correction node, what an elegant solution!
Indeed!!! I tried the color correction node as well, but didn't have any success, because I never tried values higher than 1. Brillant!


That is indeed the method I always use, just a color adjust with the altitudes of the water as borders. Keep in mind that you can use negative and positive numbers in every shader, the slider isn't all there is.


I suppose that many nodes can be used in "creative" ways, diverging from the data type they were initally intended for (at least, based on the name).
Maybe "color adjust" should be called "data stretcher"  ;D

james adamson

Hi all.
This looks great, I have a question just to help me understand whats happening in the two versions.
In your version Uuderzo, would I be correct in this understanding of your setup? That being the vector displacement is actually acting
like a Boolean. I.e the constant vector raises the ground then this provides you with a greater area of white in your mask as those areas have been raised above zero/sea level?
The higher the displacement the wider the foam?

And in your verison WAS you are grabbing hold of the hidden below zero black (below zero/sea level) and lifting them much as you have greater ranges of colour and b and w points in an exr? To essentially provide a mask for the areas at the sea level and below?
Hope I have made sense here.


Quote from: james adamson on August 07, 2020, 08:37:37 amTo essentially provide a mask for the areas at the sea level and below?
Hope I have made sense here.

That's a pretty accurate assumption. For example, you can take that Colour Adjust (unclampped) and pipe it into a displacement shader to view how the terrain differs from the original.