Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Stitching multiple terrains together?

Author
Message
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 28th Aug 2012 23:17
Hello all!

I'm using WLGfx's (at least I believe it is his, tell me if I'm wrong!) perlin noise generator plugin to generate heightmaps, which I then use for advanced terrain.

This works really well for a single terrain but I want to use paging (if that's the right term) terrain and so need to be able to use multiple terrains side by side, the noise generator is fine, the terrains are fine but for some reason they don't line up at the edges, as if there's a bit missing. I've searched the forums but am still none the wiser as how one goes about stitching the seperate terrains together? Can anyone help?

I was thinking maybe the way to do it would be to add an extra line of verticies at the right and bottom of each terrain and set their positions to be the same as the verticies along the edge of the neibouring terrain tile.

How would I add an extra line of verticies and how can I get the vertex indexes of these extra verticies so I can use them with 'set ertex position V_ID,X,Y,Z'?

For what it's worth here's the code I've been messing around with:

although it's far too messy to really show anybody, so I'm kind of embarassed to put this up here!

Any help would be appreciated,
BC
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Aug 2012 00:08
I think the solution would be to change the heightmaps so the edges match each other perfectly. This can be done with some kind of "blur", melting the edges of each heightmap together.

I'm pretty sure I can wizard some example up for you, give me a day or so and I'll see what I can come up with.

TheComet

"if you don't understand recursion than you probably don't understand recursion." ~Jerico2day
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 29th Aug 2012 00:23
Thanks, I have tried overlapping each terrain tile by one heightmap pixel on each edge but even then it didnt match perfectly! Although, I have just read a thread where someone mentioned that the AT heightmap command includes a blur of radius 2, meaning that the overlap must be 3 heightmap pixels to get around the (non-optional) blur. I'll give it a go and come back with the results!

Thanks,
BC
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Aug 2012 12:54
Doesn't AT strip away "vertex tiles" (or whatever to call it) where multiple vertices have the same position to optimize the mesh?
That could probably cause problems where they overlap.

Is there a transparent gap between the terrains (ie. no polygons there) or is it just a seam on the texture?
If the latter the settings of the overlapping vertices have to be exactly the same (position, normals and uv).


"Why do programmers get Halloween and Christmas mixed up?"
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 29th Aug 2012 17:23
@Rudolpho:

Thanks for the reply, but I'm using 4 different heightmap textures (which all match at the edges they join on) and creating 4 different terrain objects, however AT makes the terrain objects a bit smaller than the heightmap size so there is a line of 'missing' ploygons between the terrains, I say missing because if the terrains are simply placed together then they don't line up properly, they need to have their edges joined but I don't know how?

Thanks,
BC
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Aug 2012 01:48
I must admit I'm not really familiar with AdvancedTerrain.
What is it even, is it EVOLVED's terrain system in plugin form (since it's also called Advanced Terrain I believe) or something else completely? If that's the case it might be possible to figure something out but otherwise it has pretty limited publicly available functionality it seems :/
I think the intent for them is that you should onlny have the one, big terrain object.

Your best bet could probably be to make your own terrain system, there are plenty of tutorials about it around here.
I have been doing that lately so I might be able to provide some information about how I went about it if you like, not saying that my approach is optimal for all possible uses though.


"Why do programmers get Halloween and Christmas mixed up?"
Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 30th Aug 2012 09:57
No, 'EVOLVED's Advanced Terrain' handles terrain lighting only, 'Advanced Terrain' is a free command set that came with an update, it's not well documented (usually missing both help and keyword files - which can be found on the forum if you search for them) but if you've got the latest version then you've probably got it!

AT's a really easy way to make terrain using only a heightmap, texture and detail texture, it take about 6 commands to get a really nice looking terrain, and it's fast too!

The most annoying thin is that I know using multiple terrains together is possible, I've seen it on these boards! However, until I can fix this problem I'll be working on my own terrain system, like you suggersted, so any help in that area would also be welcomed.

Thanks,
BC
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 30th Aug 2012 19:29
I have recently created an LOD terrain system pretty similar to Blitz terrain. I just need to create a dll for a DBPro version, it will be free.

If you upload 4 heightmaps which 'should' join seamlessly then I will try it out with my terrain system, not tried it myself since it's not something I need right now.

If it works and you have no other solutions I will get my skates on and produce the dll asap

Note that my terrain system takes heightmaps 1 pixel more than a square number, so 513x513 or 1025x1025 etc. This makes splitting up the terrain into smaller LOD's simpler, I have noticed some other terrain systems do the same.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 4th Sep 2012 10:34
Matty H, I shall await your release

Monk
17
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Sep 2012 01:15
I haven't looked at the code, or messed with terrains for a long time so I could be barking up the wrong tree here, but....
Are the different terrain objects different levels of detail? Ie the one you're on is high detail, the others are low details, etc. If so, would that cause the miss match at the edge of the objects? Just think about having one object with twice the vertices of the other one. Then, at the edges, it would be like trying to match up a line with 10 zigzags to a line with 20 zigzags, it would have a lot of gaps.
Hope that makes sense, even if it might be completely wrong
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 8th Sep 2012 02:39
I'm also guessing the same as Monk here too. Stitching the terrains together you are going to have to compensate for the edge vertices. For the lower LOD terrains (which I'm assuming are furthest away), if they are half the detail of the center terrain then the verts should be easy to calculate and no need to grab the noise values to match them up. That will sort out any of the zig-zagging.

I don't know about Advanced Terrain though so I can't help there...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 8th Sep 2012 03:22
Could you not apply some form of smoothing around the edges for a short distance and mirror those along the facing edges of the terrains?

Broken_Code
15
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 11th Sep 2012 13:02
I don't want to reurrect an old thread but I found the cause of the problem:

No they weren't different levels of detail, I started easy to make sure I wouldn't run ito that problem; they were 4 heightmaps taken from one large image cut up into peices and all the same LOD.

I found the cause of the problem on another thread: AT adds a bit of internal blurring to the heightmap image of around 2 pixels, so by making the heightmaps overlap by 3 pixels and overlapping the terrain objects it is possible to get a smooth terrain but I wanted a proper solution so I just started my own terrain system (which I'll release on the boards if I ever finish it!).
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 15th Sep 2012 08:13
[/b]Here's an interesting practical problem/b]

How do you stitch terrain together without having visible seams in the lighting and shading where the terrain's meet?

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Sep 2012 07:21
The lighting and shading that causes the visible seams will be from the normals of the vertices. When you stitch two together you are going to have to re-calculate the edges normals.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th Sep 2012 05:55
Quote: "The lighting and shading that causes the visible seams will be from the normals of the vertices. When you stitch two together you are going to have to re-calculate the edges normals."


Yeah but how? lols I've been thinking of this for a while, just haven't had the time with other issues to look further into this.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Sep 2012 11:14
If the edge normals on one terrain are pre-calculated to the edges faces then to get the average all you will need to do is to add both of the edges normals up and divide by 2.

Psuedo code:


Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2026-07-07 20:18:00
Your offset time is: 2026-07-07 20:18:00