Spherical / Planetary terrains

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. :slight_smile:



@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. :)

For those of you who might be interested in the Sphere mapping here’s the gist of it.



The first post explains what is being done to the texture. Of course we’re not taking about a texture here, but it’s a start.

Nice!

I’d love to contribute more but with 4 projects running at the same time the best I can do is keep checking here once in a while. :slight_smile: I’m definitively interested where this might lead though.

Collision would have to change too, right now it is optimized for an axis-aligned grid.

For texturing, using the already implemented tri-planar mapping should solve any issues with squashing at the poles.



I think it is a reasonable assumption to have the world modeled as a sphere instead of an oblate spheroid. The user can just reproject their heightfields to fit the sphere, and then you would be able to possibly save on computation in real time to exactly model a planet.

Instead of using having it render the entire planet per frame, couldn’t you just attach a few un-rendered spheres to the player (like one with a radius of 125 ft, next at 250, etc.) and make it so when the terrain enters one of these spheres the LOD changes? and anything outside the spheres wouldn’t be rendered. Except you would need quite a few spheres between the player and the horizon to keep from major distortion on the horizon, like when you see a mountain from miles away, and its just a few polygons. Those few polygons should keep the basic shape so that it’s not too much different in shape when you are standing right in front of the mountain. I know that’s generally the idea with LOD, but in many games all to often you see the terrain “jumping around” and changing right in front of your eyes. And for the player, I remember seeing something last night about an improved Chase Cam. Now any time I see anything 3d, I think planets. Don’t ask why. But anyways, it made it so that when something got in the way of a ray the camera casted at the player, the camera would move closer. So how about there is a ray casted between the player and the ground. The player generally stays at the same angle as the ray, and when a hill comes between the player and the ray, the player simply moves over this hill. All you would need from there is a way to limit the player’s ability to walk up a mountain face. I’m practically in love with designing planets and such, and I wouldn’t mind helping out with some ideas on this.