This conversation started in comments to the post about TerrainGrid. I simply copy the relevant parts without modifications, and let’s see if it can be done.
@madjack:
Although it’s defined as “infinite”, is it possible to define an instance of those so it would generate a random terrain of a X x Y size that would wrap-around? Like say, if you were on a planet? Could that be done as it is now?
@anthyon:
To create a toroidal world should be no match. Create the heightmaps as usual, and create an ImageBasedGrid with a namer object that calculates the tile id like: x%horizCount and y%vertCount. You should take care though, that the first and last tiles match seamless, but from your description that should be no problem.
A spherical world is different by how you should calculate the poles. It can be really tricky, but I think it’s doable with some cheating using terrain grid.
@anthyon:
I was just thinking about planetary terrains last night, and found a viable solution, though not through TerrainGrid. If you take a sphere and displace every vertex by a value, you’ll get what you want. The main problem is, that you’ll have to find some paging algorithm, so you don’t have to draw the whole planet each rendering phase, and the movement is on the surface is a bit more complicated as well, as the user movement can be described by two angles instead of cartesian coordinates.
@madjack:
Hmmm… Maybe the “ShereMap” algorithm I used in the Texture Editor could work for that since what it does is essentially the same as it takes a square texture and “spherize” it so that it would perfectly fit on a sphere.
Thinking aloud here… Let’s say you take a 1024×1024 texture and apply the algorithm to it. What it technically does is apply a distortion. As you go North/South from the center, the biggest the distortion is. The same goes with East/West but the distortion is applied in a different direction.
If you took that texture (or rather its size) and used it to represent your planet, you could subdivide it by using a system of latitude and longitude. For each grid you have an array of horizontal and vertical distortion you have to apply for it to fit the sphere of a planet. In your case you would have to apply that distortion to vertices.
Maybe it could be tested by doing a square terrain and apply it to a sphere? It should wrap around it nicely as the texture does.
Does that make sense?
That's all now. Awaiting others opinions on the topic. :)