I'm working on a sidescroller. Tile based infinite terrain using perlin noise. That part works fine. Easy. I'm having issues with my method of smoothing the terrain tiles.
Right now, I'm using a method that pulls the neighboring terrain info as a bool - then putting it in a bool[5,5]. Then decide which terrain tile to use (as in the shape of the slope, not whether it's dirt/rock etc), I need to check these bools.
My resulting code looks like this. This is just a random example, the numbers i put are just random meaningless, but the structure is the same in my code.
int GetSlope( bool[,] ter )
{
int returnData
if( ter[1,3] & ter[3,1] ) returnData = 1;
if( ter[5,3] & ter[5,2] & !ter[4,2] & !ter[4,1] ) returnData = 2 ;
if( term[5,3] & ter[5,2] & !ter[1,1] & ![ter[2,1] ) returnData = 3 ;
and on..
and on..
}
The the return data gives me a number that indicates which tile-shape to use. Another bit of code (based on the perlin) gives me the soil type (like dirt/rock/etc)
The problem being, I'm checking a bool[5,5] to decide what tile to use. I've done this before with a bool[3,3] and it took FOREVER. There are hundreds of combinations with a [3,3]. Even more with a bool[5,5].
Just to further explain, I made a visual representation.
The black spot is the current-terrain that needs a tile texture. Green = neighbor is terrain. Red = neighbor is empty. Grey = either/or.
So, the problem isn't how to do it.. but how to do it better. If I go forward with this, I'm going to spend weeks typing out the seemingly infinite permutations. It took several mind-numbing days to do it with a [3,3].
Hopefully my explanation of what I'm doing is good enough to understand. I feel like it's not. If not, ill try to elaborate.
The only other idea I have is somehow calculating the slope, but I can't figure out how'd I'd even start to do that without resorting to an endless bool check again.
If anyone has a better idea of how to approach this, I would be eternally grateful.