Quote from: Elegy on July 19, 2009, 07:52:49 AM
Firstly, I'm quite confused about what exactly the difference is between lateral displacement, such as when you select 'Lateral Only' from within the Power Fractal, and a redirect shader with a displacement plugged into both the X and Z shaders.
In both cases, displacement is applied along only two axes - X and Z - and yet the displacements produced seem to be very different. Why is this? I know that redirect shaders 'redirect' the input along any axis but what does that mean exactly?
The Redirect Shader "tricks" the shaders which are attached to it into thinking that the surface normal points along the positive X axis, positive Y axis or positive Z axis. Basically it modifies the shading state variable for the surface normal before calling the shaders, so that they think they are displacing a surface with a different normal. Any shader that displaces along the normal will then displace along these directions. Displacement in the negative X,Y,Z directions is accomplished if the displacement shader displaces negatively (e.g. if it indents a surface rather than raising it).
Some shaders make more complicated decisions about the displacement direction, or they let you choose. The Power Fractal defaults to displacing "Along Normal", but some of its other settings allow for interesting effects. "Lateral Only" still uses the surface normal, but it cancels out any amount of displacement which occurs directly upwards/downwards away from the planet's centre. On a level surface, the surface normal points directly upwards, and the displacement will be completely cancelled out. On the side of a cliff, however, where the surface normal points away from the usual up-down direction, the displacement is much stronger. They only displacement allowed is displacement not in the up-down direction. It's a simple way to get the appearance of horizontal layers in your displacements, especially if you combine it with XYZ stretching of the noise pattern.
"Lateral Normalized" is similar to "Lateral Only" except that the magnitude (length) of the displacement is kept, and only the direction of the displacement is changed. This means that the displacement won't fade out on surfaces which are nearly pointing upwards, and you'll always get strong lateral displacement.
"Vertical Only" is the opposite to "Lateral Only", and cancels out any displacement which does not occur along the up-down vector which points away from the centre of the planet.
"Along Vertical" ignores the surface normal completely, and uses the up-down vector which points away from the centre of the planet.
Some of these names include the words "requires computed normal". A Compute Terrain node is sufficient to give you a computed normal anywhere downstream from that node. You don't need another Compute Normal node.
Quote
Secondly, I know that the Merge Shader when left to default settings is set to 'Mix' displacement. I take it this means that the mean altitude of both inputs is used as the output. But what if one of the inputs has two altitudes at one point (ie, has overhangs)? Does it simply take the mean of all altitudes at a given set of 2D coordinates?
I appreciate any answers.
The displacement vector (which includes the direction and distance of the displacement provided by a shader) is simply the weighted mean of the two input displacement vectors.
Overhangs are the result of bending the 2D surface over itself through the use of interesting displacement vectors, but each point on the terrain only comes from a single point on the undisplaced planet. It is still a 1-1 mapping from the flat surface of the planet to any point on the displaced surface. The upper part of an overhang comes from a completely different part of the surface than the lower part which it overhangs. So there is no averaging of overhanging points that overlap in 2D space, because the shaders don't even know that is happening.
Matt