annoying spikes in heightfield

Started by oysteroid, February 15, 2010, 03:22:53 PM

Previous topic - Next topic

oysteroid

Hello all! I am new to Terragen 2, having just purchased a copy a week or so ago. Learning it so far has had its share of agony and ecstasy! I hope someone can help me with a little problem that showed up that I seem to be too thick to solve.

I wanted to create a heightfield that would be just a simple cylinder, so that I could test function displacements on it. So I created an image in Photoshop that is just a white circle on a black background, with some anti-aliasing on the edge. The circle is pure white, rgb(255,255,255). But in the resulting heightfield, all along the anti-aliased edge of the circle, I get all these spikes that stick up higher than the part of the image that is pure white, and as I understand a heightfield, this should not happen. What is up with these spikes?



I attached the TGD file and the image I used for the heightfield.


This also leads me to a related question. How the heck do you set things up such that you can generate a heightfield from a simple shape shader? I just can't seem to get that to work!  :-[

Hetzen

#1
Hi there Oysteroid, and welcome to the forums.

First off, and I may be wrong, but I think heightfields don't just work in black (lowest) and white (highest). I think they use ramps of dark grey to light grey in bands like contours on an ordanance survey map, so that more information can be crammed into a 0 to 256 range that a pure black to white image would give. This could explain why you are seeing the spikes.

I've attached another method of creating your column, but using an image map shader attached to a displacment node, which will work with the rational of black is low and white is high. Something that was interesting, was seeing the jpg artifacts in the displacment, which is a good reason to keep displacement artwork at an uncompressed state (any program usually needs to keep compressed images uncompressed in ram somewhere along the line).

What TG does struggle with, is creating enough facets on a verticle surface for you to play with. It's often a good idea to make your extrusions at 'near' verticle, ie some value of blur, so that there is some form of tapering. From what I understand, the program works with top down faceting in the compute terrain node, which is why it may struggle tesselating information onto verticle sides.

oysteroid

Hetzen,

Thank you! So it seems that doing this with a displacement shader doesn't cause this problem. Interesting! I also tried the simple shape shader in place of the image map shader in your version of the file and that worked too, so that also solves my second problem. Thanks! I guess using a heightfield was just the wrong approach here, eh?

Hetzen

No problem. I wish there was something more I can add to your starfield approach, but just plugging in a high contrast noise map doesn't work properly, or more likely, in the way I thought it would.

mogn

You can also make such things without importing images or .ter:


Hetzen

Hi Mogn

Would you mind talking me through your node expression?

latego

Terragen has tremendous problems with TERs which represent heightfields with highly discontinuous derivatives (here you have a ring in which the derivative is infinite).

Luckly, this kind of terrains come only from synthetics heightfields (I am writing a terrain generator and my test pattern TERs make TG2 scream ;D).

Bye!!!

mogn

Quote from: Hetzen on February 16, 2010, 07:49:26 AM
Hi Mogn

Would you mind talking me through your node expression?

Start with the "Get position in geometry" this node delivers a X and Z value for each point i the landscape.
This is a global array of points, where the node network below calculates a scalar value for each of this points.
This means when the last node "Multiply scalar 02" delivers these values to the function input of the "Displacement shader 01"
this node uses the same points from the "getposition in geometry" to calculate where to apply that displacement.

The output of the "Get pos.." is fed into the input of "translate to [300, 0, 300]" this node is a renamed "Subtract vector".
Input2 of this node is fed from the output from a scalar node, TG2 expects a vector so change this to a vector [300, 300, 300]
and subtracts this from the current point from "Get pos..".  UPS  this is a serious error, scalar 300 should have been a vector [300, 0, 300].
In the following suppose that the output from "Get pos" is [400, 0, 400]. This notation means x=400, y=0, z=400

The output of the "translate to.." is thus [100, -300, 100]
This is then divided by 500 to give valuse so the 500m is One unit of 1/2 km. the result is [0.2, -0.6, 0.2]
This is fed into a "Clamp 01 scalar" meaning that [0.2, -0.6, 0.2] is typecasted to a scalar Length([0.2, -0.6, 0.2]) = 0.663325
This is positive and less than 1, so it passes unchanged. What happens (if I had programmed correct) is that points inside
the distance of 500 m from [300, 0, 300] is converted to a value between 0 and 1 and all distances greater than 500 is converted to 1.

This value (d) is the complemented (1 - d) by "Complement scalar 01" giving values that decreases from 1 in distance 0 to zero for distances g 500reater than 500.
Thus describing a cone with the height of 1 m and a radius of 500 m.
this is then multiplied by 10. Cone with height 10 and radius 500.
The top 9 m is the removed by the "Clamp 01 scalar 02"
The result is then multiplied by 500 to give a reasonably displacement
This finally fed into to function input of a "Dispacement" node.

It is strange that I after 48 years of programming still makes errors


Hetzen