Terrain too rough

Started by
31 comments, last by Hippokrates 18 years, 1 month ago
Actually I am using doubles during heightmap generation. After the first step of heightmap generation, the array consists of values with no upper limit (since all hills are added on top of another). These values are then normalized to an intervall between 0 and 1. Finally, when saving the heightmap, the heightmap is scaled up by multiplying the values with 255.
Im Anfang war die Tat...Faust
Advertisement
This is what I get using the Hill algorithm you mention above. I applied smoothing just once aftewards (based on a box filter from this gamedev article). It does occasionaly generate a large hill in the center, as you mention, but for the most part, it generates a good island scene. I use bytes for the height in the range 0 to 255.

Quote:Original post by Hippokrates
Actually I am using doubles during heightmap generation.


You're doing this:
int radius;double squareDistance = (centerX - j) * (centerX - j) + (centerY - k) * (centerY - k);double height = (radius * radius) - squareDistance;


The problem is you have declared radius as int. So your multiplications are giving you int's as well not doubles. This is giving you the quantized height values. Try:
double radius;double squareDistance = (double)(centerX - j) * (double)(centerX -j) + (double)(centerY - k) * (double)(centerY - k);double height = (radius * radius) - squareDistance;
One other thing, why are you doing this:

theta = (rand() % (2 * Pi)) / 1000.0f;

The division by 1000 makes theta near 0. Therefore, centerX=mapcenter+distance, and centerY=mapcenter.

Which is probably making your island look like a long cammel hump instead of spreading the hills around the map.
Changing the values into doubles did not work either :(
As for the "theta = (rand() % (2 * Pi)) / 1000.0f;": I divide the value by 1000 because Pi is defined as 3141 (since you cannot use modulo on floating point numbers)
Im Anfang war die Tat...Faust
Can you provide an image with polygon lines visible aswell? That would be helpful in diagnosis. It looks to me like some of the terrain is "stepped". That might mean its a drawing problem not a generation problem. Also it could just be that 8 bits isn't accurate enough for how much terrain you are generating.
I actually think the image is fine and to be expected. Could you post a wireframe screenshot maybe?

The image in the tutorial looks nicer, but you'll notice that it is far more dense than the lines drawn over it suggest. If they plotted that mountain only on the points where the lines intersect it would also look pretty rough.
I made a shot of the terrain in wireframe mode. I hope it will prove helpful. And this time I also used the source code provided by the author to generate the terrain. Therefore my implementation of the algorithm should have been correct.

Im Anfang war die Tat...Faust
Why is the mesh of the ground denser than the mesh of the 'mountain'?
Actually I have no idea. I am rendering the terrain with Ogre's built-in terrain plugin, using standard parameters.
But I think the ground you are referring to, is actually behind the hill - so maybe it just looks more dense because it is farther away.
Im Anfang war die Tat...Faust

This topic is closed to new replies.

Advertisement