## Displacement on near vertical surfaces -problems

Started by Roberts, February 07, 2024, 11:05:27 AM

#### Roberts

Hi all!

I´m growing increasingly frustrated with problems that occur when I want to apply displacement on near vertical surfaces. I know and (sort of) understand the issues of the terrain getting displaced vertically and as a result, "stretched". But is there any way to avoid this or any remedy? Or is this just the way TG works and cannot handle properly?

Please take a look at the renders provided that highlights the issues. To the left is a 100x100x100 m displaceable cube and to the right is a part of the planet´s terrain that is displaced a 100 m vertically by a simple shape shader, with a smooth step border of 5 m. The cube´s side are fully vertical, 90 degrees, while the terrain formed by the simple shape shader is between 85-89 degrees steep.

All renders in 0.5 micropolygon detail.

First render shows the scene with only the base colors.

Second shows the scene with the smooth voronoi only as a surface color.

Third shows the scene when the voronoi is used as displacement.

As you can see in the third picture, there are ugly artefacts on the near vertical parts of the terrain to the right. The same does not show up on the displaceable cube (i guess because it´s not part of the terrain but a separate object).

Why do these occur and more importantly, how do I get rid of them (if possible)?

I have already tried using a smaller patch size, down to 0.02 m, without any luck. I have also increased the planet´s displacement tolerance from 1 to 2. The jagged/torn edges always show up anyway (fourth picture).

Any help or pointers are most welcome, thank you.

Attatched is also the tgd.

Regards / Robert

#### Kevin Kipper

Hi Robert,

As to why this happens, imagine the bottom left corner of your simple shape shader was at the origin, with the coordinates (0,0,0).  This will be at the base of the displaced terrain feature.  When the shader is displaced 100 meters upwards, the coordinates at the new top left corner is (0,100,0).  In terms of texture space, there's "nothing" to work with on the X and Z axis, as those points basically overlay one another.  It might be helpful to think of it as a uv map with two vertices on top of each other.

If you were to apply an Edge Profile, like bevel, and an Edge Width, like 25, that top coordinate might now be (25,100,25) and you now have "more" to work with in terms of the texture space, and Terragen has better results in subdividing that area for the displacement to occur.

We're thinking about how to best address this situation, and were hoping you could share a bit more about what you're trying to accomplish.

#### Roberts

#2

" We're thinking about how to best address this situation, and were hoping you could share a bit more about what you're trying to accomplish. "

The short answer is that I want the displacement to be applied to and work on the near-vertical part of the terrain in the same manner as on the cube, that is the look I´m after.

I understand the concept you are describing, that two points that are originally very close to each other became displaced and pushed further apart. But as you may notice in my node network, I have a "Tex coords from XYZ" node before the lateral displacement takes place on the vertically raised terrain, which should (?) feed the following shader the information needed. The strange thing is that the Voronoi noise does not look "stretched" or distorted when used only as color, but it looks VERY distorted when used as displacement.

Again thank you for input and help.

Regards
Robert

#### aknight0

If Terragen had some way to retopologize the surface after vertical displacements it would open up incredible possibilities.  Trying to get lateral displacement to work properly is always such a pain.

#### Roberts

#4
Yes Aknight0, something like that I guess. But like i pointed out before. The voronoi noise is NOT very distorted when used as color only, after a "Tex coords from XYZ", so somehow that shader "reads" the surface correctly. Despite this, if the same noise is used as displacement, the surface looks distorted. I don´t really understand why that happens. The "Tex coords from XYZ"-node should act somewhat like a "retopologizer".

And from a more practical and artistic viewpoint, it is weird if a terrain renderer cannot handle near vertical surfaces in the terrain. Somehow the terrain surface in TG has limits, it´s more like a spherical membrane. A balloon that can only be inflated to a limit, before it breaks. It seems strange that one of those limits appears to be the (in)ability to handle steep cliffs, for example.

#### Dune

The balloon idea is indeed what it is, hence you can also get overlaps of the membrane (different from a real balloon), which can be annoying.
If you use a compute terrain and some displacements after that for rock, it usually works pretty well, especially if you have some roughness in the displacements. But the preview looks rather different from a render.
For close-up of a rock face, a cube may be better than a displaced planet.

#### Roberts

#6
Quote from: Dune on February 19, 2024, 10:10:22 AMIf you use a compute terrain and some displacements after that for rock, it usually works pretty well, especially if you have some roughness in the displacements. But the preview looks rather different from a render.

Thank you Dune for answering, I appreciate it. Do you mean I should try putting a compute terrain node below the rock displacement (in my case the voronoi noise) and also add another layer with some displacement?

#### Tangled-Universe

Hi Robert,
This is a recurring discussion, so it's not only you struggling with it, sometimes I still need to wrap my head around it a little as well.
Dune said the most important part. A cube works because it has proper normals and thus tends to behave more as expected.
As Kevin explained you need a bit of softness in your simple shape to make the wall <90 degrees so that the compute terrain node can sample the transition more accurately.
With zero softness the transition from non-displaced to displaced is literally infinitely small and therefore impossible to sample properly. In order to 'ease in' the displacement you need to add a bit of softness in your simple shape.
The same accounts for the type of voronoi you chose, that one has quite sharp transitional areas as well, so all in all this might perhaps be the hardest situation you can throw at the design of this software.

The softness make the shape less vertical of course, but that can be compensated for by applying some lateral displacement down the line, after you have applied all your fancy displacements.

I have a TGD attached which demonstrates this. It also shows you can do this without compute terrain tricks. Just plugin the unused compute terrain and see that it still works.
Check how this affects the shape. Basically the gradient patch size not only determines the "resolution" of how the terrain is sampled, it also determines how fast a normal can change direction over that gradient patch size.
So the smaller it is the more wild your displacement can behave. Therefore it's always wise to start with large scale displacement and work your way down, then you rarely run into issues with the gradient patch size.

Hope you find it useful.

Cheers,
Martin

#### Roberts

Thank you Martin! That is very kind of you to share your insights and the file. I will have a look. I understand that rapid changes are very hard for TG to handle, I just thought I had avoided that problem by making the wall steep (but not fully vertical) and by using the smooth voronoi instead of the harder one. But I will definitely check your example and experiment some more.

Many thanks!
Robert

#### Tangled-Universe

Hi Robert,

No problem, you're welcome... Got any luck so far with it?

#### Roberts

Yes, Martin. It's looking very promising, thank you. I'll post an image  when I'm at the computer😉

#### Roberts

#11
Here´s a screeshot of my scene using you approach Martin. Much better! The displacement from the voronoi is not nearly as distorted as it was with my previous attempt. I know it´s not a pretty scene, but it´s just for trying out the concept :-) Thank you so much, this has been really helpful and I´ve learned valuable things. Also attched is a rocky pillar, which looks more like what I´m after.

Best regards
Robert

#### Tangled-Universe

Nice! Glad to hear it helped and it also looks like it

#### Dune

Interesting, and nice result. I guess it's strata shader low octave over lateral bumps, and one or two hard warps?

#### Roberts

#14
I´m not sure exactly what setup I used for that render, but here is an attempt at a step by step explanation (sorry for the images not showing in the right order):

Step 1: Basically TU´s initial displacement of the simple shape forming the pillar. It´s a PF that is stretched in XZ and Y.

Step 2: Barely visible, it´s a voronoi diff and a voronoi cell that are combined to make a facetted look.

Step 3: A larger version of the voronoi mix in the previous step, to make some vertical angular bulges.

Step 4: A strata and outcrops shader, I think it´s the same that TU added.

Step 5: Gradient ramps using modulos and linear step.These are merged and rotated to run in X and Z directions. Used for making some sharp ridges on the cliff (they could perhaps be restricted to only be applied to the cliff facing in their respective directions. Now they go "around the corner" so to speak)

If you want to have a look at the mess I have attached the tgd.