making terrain's connect together

Started by
12 comments, last by fireking 20 years, 6 months ago
ok, ive reached my end! ive got a terrain, here''s the process huge ass map was created, its 256 blocks of 256x256 arranged in a square (128 blocks by 128 blocks, each 256x256pixels). Each block is then taken into photoshop, resized to 1024x1024, and saved as a .raw file. That .raw file is then loaded into the application, and rendered 10''s bigger (glScalef(10,10,10)). Alright, everything is great, except the maps dont want to connect together exactley right. I know each image lines up EXACTLEY cuz it was compiled in a HUGE map then cut up. why dont the terrains line up in the program? Is it because we''re guestimating by using a step size of 16, and that very slight short cut is making it so that they dont line up? if so, whats a really inexpensive way of conneting terrains... also, for future question i know i will have, how could i dynamically load and unload terrains as the player is walking around, i cant render 256 10240x10240 terrains all at once i also plan on adding dynamic dynamic detail textures (double dynamic intended). Im not sure how i will do this, but i want to, visually, have the detail texture decrease in detail as landscape moves farther from the camera, so that it doesnt appear so (plain). Yes less detail, farther away, will make it look better cuz its scaled across the terrain less, and from far away that looks better.
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
Advertisement
What does each pixel in the heightmap represent? The quad or the vertex?
-Ostsol
When you cut the large image apart, did you overlap the border? Let''s just say for now that you are cutting the image into 2 halves. It seems to me that there needs to be a row of pixels that both halves share in order to get a smooth transition between one terrain section to the other. Otherwise you''ll be missing a strip between each section or it might appear to take a jump instead of lining up smoothly. If that''s not clear, let me know and I''ll try to explain what I mean more clearly.
hey mr. grinch...

i decided to do some more work with this quesiton, and now ill post some images of what im talking about

just for ya info, i used photoshop to do everything, and im cutting the image up into slices, so that every block is exactley 256 x 256

Here is a link to the entire image, beware, its quite large...

entire world image, in low quality jpeg format

Here is images 85,86,and 101. They connect together like so:



here are the images





im am pretty sure that these should line up exactley!

also, if you dont mind, please explain in better detail what you were talking about, and thanks!
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
hey ostol, im not sure what each pixel represents, but if i show you my rendering routine, im sure you can figure that out... im guessing each pixel determines one of the verticies

int ix;	int iz;	for(iz=0;iz < MAP_SIZE-1;iz+= STEP_SIZE)	{		glBegin(GL_TRIANGLE_STRIP);		for(ix=0;ix < MAP_SIZE-1;ix+= STEP_SIZE)		{			SetTextureCoord((float)ix,(float)iz);			glNormal3f((float)ix,(float)Height(pHeightMap,ix,iz),iz);			//glNormal3f(0.0f,1.0f,0.0f);			glVertex3f(ix,Height(pHeightMap,ix,iz),iz);			SetTextureCoord((float)ix,(float)iz+STEP_SIZE);			glNormal3f((float)ix,(float)Height(pHeightMap,ix,iz+STEP_SIZE),iz+STEP_SIZE);			//glNormal3f(0.0f,1.0f,0.0f);			glVertex3f(ix,Height(pHeightMap,ix,iz+STEP_SIZE),iz+STEP_SIZE);		}		glEnd();	}  


the Height() function returns the current value (we use it as y) at that location (specified by x,z) in the array of the .raw file.

[edited by - fireking on October 20, 2003 9:21:50 PM]

[edited by - fireking on October 20, 2003 9:22:47 PM]
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
i think wat mr grinch meant is this.. take the following grid for example:

. . x .. . x .. . x .. . x . 


assume all points (x or .) are pixels on the raw image. if u cut the image along ''x'' u will have two images like the following:

   (1)      (2). . x        .. . x        .. . x        .. . x        . 


now THAT is a bit wrong to store them coz the columns 1 and 2 are two diff values but they represetn edges of a sub-grid. what they SHUD look like is as follows (i think):

. . x       x .. . x       x .. . x       x .. . x       x . 


the images shud have one common column so that the rendered vertices coincide.

another note, do NOT resize the images AFTER splitting them up unless u use nearest neighbour filtering in photoshop. Any other filters will cause slight mismatch in the value on the edges of adjacent grids. BUT even using nearest neighbour, u''re overall grid might end up looking rough. Think about it.
- To learn, we share... Give some to take some -
im hoping the nearest neighbor thing works...

i do not want to end up programming some sort of (fill in the gaps) algorithm, cuz thats just too costly and really a cop out job... i want the terrains to fit together without hassle.
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
nearest neighbor not working... grrr
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
I think the other responders got what I was saying, but I'll try to illustrate it a bit here. For this example, I'm just going to talk about a 1D array, but it works the same for 2D. Ok, let's say you have an array of floats for the heightmap:

float heightmap[4]; // Small terrain for this example

Ok, now let's say the values of those array elements are:
{1.0, 2.0, 3.0, 4.0}

Picture it as a steadily increasing terrain (height goes from 1 to 4). Ok, so now you split that into 2 terrain sections right down the middle. When you draw the sections, you draw polygons (triangles, quads, whatever you do) between 1.0-2.0 in your first section of terrain. Then, your next section of terrain draws the polygons between 3.0-4.0. However, when you split it, you basically lost the drawing between 2.0-3.0.

So my suggestion is to re-split your image so that each section shares it's borders with the sections around it. In the example above, instead of making two sections of 1-2 and 3-4, you would make two of 1-2 and 2-4. That way when you draw your sections, you draw 1.0-2.0 in your first section, and 2.0-3.0-4.0 in your next section, given you a smooth border. I expect that may get a little more complicated if you add LOD, but it should be pretty similar to other crack fixes. Is that more helpful? I'm afraid this didn't come out as clearly as I hoped, so let me know if I can explain something more clearly.

One more thing: if you stuck the 1-2 and 3-4 sections together, they would seem to make a complete image. However, when drawing vertices of the heightmaps, remember that it is the polygons between the vertices that make it seem continuous. The sections need shared vertices.

[edited by - Mr Grinch on October 20, 2003 11:10:17 PM]
i understand what your talking about, but how to i split my images so that they share a border? this is a huge map, so whatever process would hopefully be batchable (new word of the day) cuz whatever that process is, i have to do it 256 times...
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios

This topic is closed to new replies.

Advertisement