Real Software Forumshttp://forums.realsoftware.com/ Anyone got a simple Tile Terrain Tranistion algorithm?http://forums.realsoftware.com/viewtopic.php?f=4&t=45220 Page 1 of 1

 Author: DaveS [ Sun Sep 02, 2012 6:37 pm ] Post subject: Anyone got a simple Tile Terrain Tranistion algorithm? I have a tile based game where the terrain is made up of combination of eight(8) tiles (grass, sand, alphalt, dirt,water etc.)I have figured out a quick easy way to create edge transitions giving each tile type a priorty (grass is highest, water is lowest) and using grayscale masksbut it only works for top, bottom, left and right edges.... I cannot figure how to make the corners look good.This is most probematic when a corner has multiple types of terrains involved. 99% of the "tutorials" on the web talk about terrain consisting of two types of tiles (grass and water).. I need at least 3 (grass, sand, water) but would prefer the 8 I have.I have come up with two concepts.... but am still perplexed about handling corners.`+---+---+---+| 1 | 2 | 3 |+---+---+---+| 8 | X | 4 |+---+---+---+| 7 | 6 | 5 |+---+---+---+`Assuming "X" is the tile being analyzed.... my first idea would be to examine the 8 neighbors and create a mask to apply to "X" that would allow each of its neighbors to encroach inside "X"The other would be to create masks to have "X" encroach outside onto each of its neighborsBut either way... the corners are the issue. If 2,3 and 4 were all the same terrain ... no problem... but if each were different..... then what do you show? and how do you show it?My terrain tiles are 102 x 102 pixels so I have enough resolution to work with. Any specific help would be great!and gee.. if anyone even felt like taking my tiles and writing a little demo.... here is a partial screenshot of what I have so far (as you can see it REALLY needs some blending)Note.. the TRACKS are a layer all their own.... so there is one image of TERRAIN tiles (above) and another for TRACK (and soon to be another for Buildings and bushes)The (hopefully) end result will be a virtual "toy" train set. Build your layout.... place your trains. Drive them around the layout... all without losing 3/4 of your garage.

 Author: MonkeybreadSoftware [ Mon Sep 03, 2012 3:27 am ] Post subject: Re: Anyone got a simple Tile Terrain Tranistion algorithm? blend them together.Add a mask to the top left of each tile which gives one pixel row/column with 25%, one row/column with 50% and one row/column with 75%. Than draw each tile 3 pixel overlaying the other one on left/top. This way you'd have a more soft edge.GreetingsChristian

 Author: DaveS [ Mon Sep 03, 2012 9:32 am ] Post subject: Re: Anyone got a simple Tile Terrain Tranistion algorithm? MonkeybreadSoftware wrote:blend them together.Add a mask to the top left of each tile which gives one pixel row/column with 25%, one row/column with 50% and one row/column with 75%. Than draw each tile 3 pixel overlaying the other one on left/top. This way you'd have a more soft edge.GreetingsChristianChristian... did you even READ my post? Quote:I have figured out a quick easy way to create edge transitions giving each tile type a priorty (grass is highest, water is lowest) and using grayscale masksbut it only works for top, bottom, left and right edges.... I cannot figure how to make the corners look good.This is most probematic when a corner has multiple types of terrains involved.

 Author: MonkeybreadSoftware [ Mon Sep 03, 2012 10:01 am ] Post subject: Re: Anyone got a simple Tile Terrain Tranistion algorithm? Sorry. I missed those lines.On the corners, I would simply use roundrect drawing commands for creating the mask.so on the edge the transparency is even higher, so 4 tiles meeting there give 100%.GreetingsChristian

 Author: DaveS [ Mon Sep 03, 2012 10:09 am ] Post subject: Re: Anyone got a simple Tile Terrain Tranistion algorithm? But that does not answer the question.Putting a simple corner shape mask is one thing.... but the question is how to handle the fact that any given corner can have 2,048 combinations of neighborsHow BEST to decide WHICH terrain to apply that mask to? Inside? Outside?I am going for a blend mask solution, as I dont want to spend the next year or two hand drawing custom tiles for a program that only took a few days to write.Am finding it quite frustrating that there are hundreds of articles on the web, but not a single one of them discuss specifics... they are all 30,000 foot level explanations

 Author: DaveS [ Mon Sep 03, 2012 3:42 pm ] Post subject: Re: Anyone got a simple Tile Terrain Tranistion algorithm? Not Perfect... but much better....... still need to tweak it some BEFOREAFTER