T3D 1.1 Stitching multiple terrain together and background loading
by Jack Stone · in Torque 3D Professional · 12/23/2012 (1:25 pm) · 4 replies
I have recently been doing some work on the T3D terrain system, creating multiple, random, terrains files and placing them in the same mission. I posted a more detailed analysis of it here:
http://phoenixgamedevelopment.com/blogs/index.php/2012/12/23/astral-realms-ms2-terrain-paging
This is working very well, but I have two problems.
The first is a visible seam between each terrain block, which seems to also act as an "invisible wall" in some cases to stop the player from walking onto the next terrain. I can just about leave with the visible seam, I can cover it with vegetation, etc, but I need to solve the issue with the collision. Does anyone have any idea why placing two terrains next to each other would cause collision issues for a player travelling between them?
The second thing is that loading new terrains freezes the game, which I would like to avoid. What I really need to do is load the terrains in the background, without freezing the game. I did a search for "background loading" but it didn't turn up much, does anyone have any more information on this?
http://phoenixgamedevelopment.com/blogs/index.php/2012/12/23/astral-realms-ms2-terrain-paging
This is working very well, but I have two problems.
The first is a visible seam between each terrain block, which seems to also act as an "invisible wall" in some cases to stop the player from walking onto the next terrain. I can just about leave with the visible seam, I can cover it with vegetation, etc, but I need to solve the issue with the collision. Does anyone have any idea why placing two terrains next to each other would cause collision issues for a player travelling between them?
The second thing is that loading new terrains freezes the game, which I would like to avoid. What I really need to do is load the terrains in the background, without freezing the game. I did a search for "background loading" but it didn't turn up much, does anyone have any more information on this?
#2
It won't solve your problems, but you might find this thread interesting:
https://www.garagegames.com/community/blogs/view/22029/
I too would love to figure out how to load terrains in a background thread, haven't done that much with threading personally... I worked around the problem by using tiny terrains (256x256) and using a lot of them, this makes the loading lag small enough to be not very noticeable, but it exacerbates the black line problem.
If you read all the way down to the bottom in the comments, Andy Wright has some useful observations on that issue - it appears that for each terrain tile, Torque is invisibly wrapping each edge with one line of vertices from the opposite edge of the same time. If you look closely, you will notice that at places where the terrain is lower on this edge and higher on the opposite side of the same terrain, the shading will be on this side of the line, and you will have a difficult time crossing the border. However where the terrain is higher on this edge then you can cross easily and the shading will be on the other side. (This may not make sense the way I'm explaining it, but if you look closely you will see what I mean.)
It appears to be possibly a holdover in the lighting and collision systems from the time when Torque always tiled terrains? Maybe? I have not found a fix yet, but that is the best description of the problem I can come up with.
12/28/2012 (11:16 am)
Hey Jack, It won't solve your problems, but you might find this thread interesting:
https://www.garagegames.com/community/blogs/view/22029/
I too would love to figure out how to load terrains in a background thread, haven't done that much with threading personally... I worked around the problem by using tiny terrains (256x256) and using a lot of them, this makes the loading lag small enough to be not very noticeable, but it exacerbates the black line problem.
If you read all the way down to the bottom in the comments, Andy Wright has some useful observations on that issue - it appears that for each terrain tile, Torque is invisibly wrapping each edge with one line of vertices from the opposite edge of the same time. If you look closely, you will notice that at places where the terrain is lower on this edge and higher on the opposite side of the same terrain, the shading will be on this side of the line, and you will have a difficult time crossing the border. However where the terrain is higher on this edge then you can cross easily and the shading will be on the other side. (This may not make sense the way I'm explaining it, but if you look closely you will see what I mean.)
It appears to be possibly a holdover in the lighting and collision systems from the time when Torque always tiled terrains? Maybe? I have not found a fix yet, but that is the best description of the problem I can come up with.
#3
Chris, that is exactly the kind of behaviour that I am seeing! You explained it very well, in some places I can walk from one terrain to another, and in others I can't.
It seems then that I need to find and remove this legacy code? I remember in the old days Torque had infinitely tiling terrain, where the same terrain block would repeat in all directions, giving the impression of a huge world, even though there was only one terrain block in use. I suspect this edge wrapping is in some way related to that?
In any case, I will look into it. Thanks a lot for your help!
12/29/2012 (9:32 am)
Richard, threading is something I have never really looked into, I will have to read up on that. Thanks for your advice!Chris, that is exactly the kind of behaviour that I am seeing! You explained it very well, in some places I can walk from one terrain to another, and in others I can't.
It seems then that I need to find and remove this legacy code? I remember in the old days Torque had infinitely tiling terrain, where the same terrain block would repeat in all directions, giving the impression of a huge world, even though there was only one terrain block in use. I suspect this edge wrapping is in some way related to that?
In any case, I will look into it. Thanks a lot for your help!
#4
https://www.garagegames.com/community/forums/viewthread/131904
Which is a fix for the terrain edge problem on older version of Torque, but I can't seem to find where this bug actually appears in more recent versions of T3D. The getHeight() functions that I have found don't seem to have anything to do with edges?
This one here for example:
Any ideas where to start looking? If I found the source of the bug, I'm pretty sure I could fix it.
12/29/2012 (11:44 am)
I found this link:https://www.garagegames.com/community/forums/viewthread/131904
Which is a fix for the terrain edge problem on older version of Torque, but I can't seem to find where this bug actually appears in more recent versions of T3D. The getHeight() functions that I have found don't seem to have anything to do with edges?
This one here for example:
inline U16 TerrainFile::getHeight( U32 x, U32 y ) const
{
x %= mSize;
y %= mSize;
return mHeightMap[ x + ( y * mSize ) ];
}Any ideas where to start looking? If I found the source of the bug, I'm pretty sure I could fix it.
Torque Owner Richard Ranft
Roostertail Games