basic terrain modifications, like 'chop off the peaks', eludes me

Started by shadowphile, September 13, 2009, 08:24:50 pm

Previous topic - Next topic


Just starting to experiment with functions.  I have no problem with the maths, and the concept of type conversions.
What I can't figure out is the flow.  Did my due diligence on the function threads, no luck.

I have a PFS displacing a terrain.  It's a good terrain but too spikey.  I would like to level them out above a certain altitude.
At this point I'm not even sure if a function is what I want.  Perhaps this is a straightforward blend between two shaders (my PFS and a flattish terrain) based on an altitude constraint?

Attached file is attempt to do this, but it ain't working!  It doesn't really do what I want anyway because I don't want to layer a flat area onto the peaks so much as replace them.  Further work with the merge shader isn't working either.  :(

I finally got the merge shader to work because it has a simple altitude mapper that would allow me to use a flat elevated surface to slice off the peaks.  This is not good enough though.  I need to find an approach that smoothly flattens most of the (large) peaks, regardless of altitude.  The surface layer shader seems to have the altitude/slope tools I need but I don't know how to make that work...

Henry Blewer

I added a clamp scalar to the power fractal. I also used a strata and outcrops shader before the compute terrain. Finally I changed the vertical displacement into normal displacement on the surface shader.
If you changed the normal displacement to lateral displacement, and added a compute normal before in surface shader it would enhance the flattening. The compute normal is plugged into the surface shaders input. The compute terrain is plugged into the compute normal.
Forget Tuesday; It's just Monday spelled with a T


thanks for the reply njeneb, although I'm having problems with it  ???

I opened your example.
-I can't see how the clamped scalar works as an input.  Is it passed in as some kind of rule or something?
-I disconnect the clamped scalar and I see no difference.
-Although the strata shader is perhaps a good next step for my PFS, I don't see how it accomplishes the task of cutting down the peaks and besides, forces a particular morph on my entire terrain.

I'm still very confused about functions too.  I don't know how to integrate them with shaders.  Functions seem to be always passing a kind of value.  How do I connect them to shaders that can carry multiple kinds of information at once without the function stripping out everything but the type of data it generates?

Let me be more clear: the examples I find always generate data from scratch using the position data, but I would like to interrogate an established shader and either change it directly or generate a new shader that is the result of my applying the function to the shader results.

Henry Blewer

Clamp scalar- It limits the next 'item' in the structure. So I used min 0 and max 400. It's supposed to limit the output of the following shader/function to fall between these numbers. I'm probably wrong. Many of the function do not seem to work the way I think they should.
I use the strata shader to make mesa structures. This link goes to one of my landscapes in which I used this.

I'm not good with functions, actually I don't understand them. Volker's posts are probably the most relevant for using them. Sorry if I can't be of more help. I have to go to work, and I usually have some time to think about things. I may have something tomorrow.

EDIT: Height fields are easier to control than power fractals. The second input below the 1000  1000
sets the size of the terrain.
Forget Tuesday; It's just Monday spelled with a T

Volker Harun

The main problem for me would be to clamp displacement data. I have no idea how to do it.

Else it would be possible to use the colour information of the PF and plug it into a seperate displacement shader.

I think the easiest way for you would be, to reduce the Spike Limit in your terrain node significantly. Try a value of 0.9 for a start.
This keeps the overall shape of the terrain, but smoothes most of the spikes.



I'll try out the despiking on my project, but I'm now distracted by figuring out how to work the functions.
I'm trying to modify existing displacement data and the closest I can come is in the example, although it doesn't work right.  I think you can see what I'm trying to do with nodes. 
-extract the elevation data, then use it as displacement data elsewhere (or do math on it first..)
-my example has two PF shaders,  unrelated.
-the result acts more like some kind of unh, no math name for it.  When the input node displacement is zero, then the displacement shader function input has NO effect.  When the input node displacement contains non-zero amplitude, then the function input data is added, but its scale seems to be synced with the input node data.  ??? ??? ??? ??? ???
14 hours on Terragen today, one step gained. (and that was about 8 hours ago)

So, am I completely missing something here?

Volker Harun

First thing is ... you need the 'Compute terrain' before getting altitude data.

Second, the 'Get altitude' node has an input, but as far as I know, it is ignored.

The Get-functions:
If you have an image, and we call the width 'W' and the height 'H' and the upper left corner of your image has the position of W=0 and H=0 ... now think of a ray, that is poked vertically into the landscape-image ... this ray will meet the terrain or atmosphere or whatsoever.
If the ray meets the terrain, the Get-functions give you the information about this intersection ...
You get the altitude, the slope, the normal, the position and so on. This information can be used for functions as an input.

Before I will be able to provide a solution, I would like to know what you were trying to achive, exactly - as I did not get the point ;)
Okay, you have the base terrain, and you want to modify it with the second terrain ... to add displacement (the higher the more or less)? The displacement shader in your project has an amplitude of 0 ???
Give me a hint ;)


Do you only want to make mesa structures?
If so then I have a fairly easy way of doing it using highly contrasted powerfractals connected to a displacement shader.
I used it in this image:

I can post the base of this setup.



This problem started out as a quest to chop the peaks off of my mountains.  I did not see an obvious way to do it except via my experience with programming and math, so I thought the most straightforward way was to read the displacement data, modify it, then stuff it back into a NEW shader with all the same settings as the first shader, EXCEPT I would use my modified displacement data to define the displacement function, rather than slather it on the top of another layer, which seems to be the normal operation in TG.

At this point I don't care about the mesas that much.  I encountered a problem that I want to learn how to solve on my own using approaches I'm familiar with, if possible.  My brain sees a programming environment and is trying to learn how the rules work.  I'm not so good at memorizing solutions, and tomorrow I will just encounter another task with no recipe in my book.

oh yeah, Volker's description of the Get Functions.  That is exactly how I recognize how they work.  One question that stumps me though, if the input port is ignored: since I'm building up my terrain using a series of displacements, then where in that series does my Get Altitude work?  After the final Compute Terrain?  What if I want to query a terrain value from earlier in my build-up?  It would be natural to assume that is what the input port is for.

Then there is the question of how altitude is represented.  Is it a scalar?  If I want to use it as a function input in a displacement shader, will the values translate directly to height (with the multiplier set to 1 of course), or do I need to find a way to scale it down to fit within a 0-1 range, ie like a luminosity.  Normally in a programmable environment such as this there are clear definitions, but in this case there is so much polymorphism (type casting) going on that it's impossible to determine anything without very hard trial and error.

Volker Harun

Okay ...

first of all duplicate your base terrain node ... edit the Copy like this:
In the colour tab turn the High colour black, turn the Low colour white. Be sure that both colours are enabled.
Uncheck the clamp-colours at the bottom and lower the Roughness to values of about 0 to 0.2.
We are going to use this Copy as blending shader for height, therfore there is no much need for details and displacement. So turn off the displacements in the displacement tab.
You can also raise the Smallest Scale in the Scale tab to reduce the octaves and calculation time. Smallest scale and roughness go hand in hand. With a roughness of 0 the smallest scale is ignored.

Now tho the main tweak. Take the output of Copy and drag a connection to the Blending shader input of the base terrain and activate at the very bottom of the Base terrains 'Blend by shader'.

This will smooth down the tops of your terrain. Adjust the Low Colour of the Copy and the colour contrast to your needs ;)



Volker, could this same technique be applied to an Alpine? It doesn't have the colour inputs, so my first guess is no, but perhaps you have some cunning manipulation up your sleeve?



can you still post your base mesa setup, i have my textures etc for mesa, but am still having trouble getting a decent shape


Volker Harun

Hi domdib,

I would use a workaround:

Because heightfield render faster than procedurals ... and the alpine is a very slow procedural, I export the area of interest as a heightfield. The original terrain is most often obsolete after that, but can be kept active for the background.

With the same technique you can export the terrain as OpenExr. I have not tried to blend anything with an Exr-image, if it is not possible you can convert it to a BMP, Jpeg or whatsoever before applying as a blendshader.

So you need to place heightfield to the area of interest, place an orthographic camera above this area with the FOV adjusted to the heightfield's dimension and use this camera for an image shader.

Another way ...
For either terrain you could use the merge shader.
Make that copy of the terrain node, adjust the Copy's settings to your needs and set the Merge shader's Choose by altitude to 'Cut'.



Volker, thank you for that workaround - I've been wrestling with an Alpine for a while now, and I can see how many options this opens up.


Having had a shot at trying this Volker, I confess I'm not clear on your instructions. So I set up an orthographic over the point of interest, and then what? How does an "image shader" come out of this? DO I need to render from here? If so, do I need to switch atmosphere off? Does the sun have to be at the same heading as the ortho??