Hi Calyxa,
It's a very good question, that's why it's taken a while to come up with an answer
The important thing to realise here is that many of the shaders in Terragen are designed to
modify the input
surface. They are not simply functions that generate data. Any shaders that perform displacement, such as the Power Fractal, will modify the existing surface. They do not "generate" displacement data as such, but they modify the existing surface. In most cases, displacement is an additive process, but not all (the heightfield shader with its default settings will mix in the new altitude, for example). Displacement shaders usually apply to whichever surface normal was most recently computed, but some displacement shaders choose which direction they want to displace in so that they can do more interesting things.
Any colour data from shaders, on the other hand, is usable as a function much more generally throughout TG. Usually shaders that generate colour data also modify any colour data from input shaders (ie. the Surface Layer allows some of the input colour to show through while replacing other parts with its own colour), but if there is no input you can think of them as simple colour generators.
The decision to treat shaders as
surface modifiers rather than simple functions was made very early on in TG2's design. This was done so that shaders can be thought of as layers, which is a familiar concept from 2D paint programs (and also the surface mapping system in the old TG v0.9). Allowing a shader to do many things at once (not just generate a single colour value) also has many benefits, such as applying new layers with different characteristics for specular, luminosity etc. For some people this integration of colour channels at the shader level causes problems, but there are many advantages if you can treat shaders as layers of material applied to underlying materials.
As you know, there are situations where you want to be able to manipulate the displacement data as a function. That's why Function nodes were introduced into TG2 more recently in its design. Function nodes are coloured in dark blue, in contrast to shaders which are red. If you want to perform the kinds of functional manipulation of displacements that you are talking about, in the current version you will probably need to use Functions.
So that it is easier to use any existing colour shaders within the Functions network, and also allow Functions to do anything that was previously expected of colour shaders, Functions and colour shaders are interchangeable (Functions are actually a special type of shader that just generate colour data).
There is a glaring omission from the Function nodes available in TG2 currently, and that is a "Displacement to Function" node of some kind. This would allow you to take some displaced surface (such as one generated by the Power Fractal), manipulate the displacement value by a network of functions, and then replace the original surface with the new functional surface.
There may be some workarounds though. There is a "Get Altitude" Function. It takes no inputs, however, for consistency with all of the other "Get" Functions. It looks at the current render state or shading state (ie. the displaced surface) and retrieves the altitude. You can use a Merge Shader and Displacement Shader as follows:
"Mix to A" = 1
Connect the procedural terrain into the "Input node" plug
Connect the Displacement Shader into the "Shader A" plug
Create a function network and plug it into the Displacement Shader
The Function network can now start with a "Get Altitude" Function and you can manipulate it however you want. It just needs to end with a Displacement Shader, plugged into the second input of the Merge Shader.
It's not ideal, but it is a result of the design decisions I took very early on in development. We might be able to make it easier in future by packaging up the whole Merge Shader / Displacement Shader mallarky into an easy to use "Modify Displacement" setup or something like that.
Before the Function nodes were implemented, I had planned to make a bunch of shaders that would allow common manipulations of terrain data, but since the Function network allows all of that and more it may be better to concentrate our efforts there and make it easier to integrate with the displacement shaders.
Matt