x


Spherical Terrain Object?

Is it possible to create a terrain object from a sphere?

I'm building a "Little Prince" type planet that the game camera rotates around and would love to use the super optimized terrain to build up the exaggerated mountains.

Is there a way to use a quad mesh object as a stand-in for terrain that the terrain tools will work on?

I can build my own mesh, but it will likely be a lot heavier than a terrain object.

This new Q&A site ROCKS, BTW.

Spence.

more ▼

asked Nov 17, 2009 at 10:04 PM

spencer lindsay gravatar image

spencer lindsay
222 19 18 35

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Terrains are only height maps on planes... there's no spherical support that I'm aware of. Depending on your needs, you may be able to fake something by putting multiple terrain objects together, but you're probably just going to have to model your terrain in a 3D program.

more ▼

answered Nov 18, 2009 at 12:50 AM

screenhogdotcom gravatar image

screenhogdotcom
66 3

As I thought. Although,.. with some geeking it should be possible to map Spherically onto a quad mesh sphere and use the same code, no?

Most likely,... no.

Nov 18, 2009 at 05:04 AM spencer lindsay

That's not really feasible, sorry.

You should just model the planet as a normal mesh. And setup your own radial gravity :]

Nov 18, 2009 at 03:32 PM robert ♦
(comments are locked)
10|3000 characters needed characters left

You can't use unity's terrain engine at all to make spherical terrains, even by putting multiple terrain pieces together. Much of the optimisation done within the terrain engine relies on the terrain being a flat horizontal plane which is deformed upwards only by the heightmap. Same with the trees & grass system, etc - all designed to work on terrain which lies on the X-Z plane. For this reason, the rotation controls in the inspector of the Terrain GameObject have no effect at all.

The most common way of achieving spherical terrain that I've seen is to build your own "CubeSphere" using 6 heightmaps, one for each side of the cube. I've done this before, and I've seen at least two other people on the IRC channel accomplish it.

The technique is essentialy this:

  • Generate 6 heightmaps which seamlessly join in the same way that a skybox joins.
  • Use Unity's mesh building API to build each side of your CubeSphere separately
  • For each side, you need to 'Spheriphy' the grid mesh which makes up the cube's side, and then add on the value from the heightmap for that side. My code for determining the position of a vertex on any given side of the CubeSphere looks like this (x & y is the position within the heightmap for the side):

    // first calculate as if this is the top side
    float yi = planet.baseHeight + altitude;
    float xi = ((x / (float)planet.mapMax) - 0.5f);
    float zi = -((y / (float)planet.mapMax) - 0.5f);
    Vector3 v = new Vector3(xi, 0.5f, zi);
    v.Normalize();
    v *= yi;
    
    
    // rotate according to side orientation
    switch (side.orientation)
    {
        case Planet.Orientation.Top: break;// nothing
        case Planet.Orientation.Bottom: v = new Vector3(v.x, -v.y, -v.z); break;
        case Planet.Orientation.Back: v = new Vector3(v.x, -v.z, v.y); break;
        case Planet.Orientation.Front: v = new Vector3(v.x, v.z, -v.y); break;
        case Planet.Orientation.Left: v = new Vector3(-v.y, v.x, v.z); break;
        case Planet.Orientation.Right: v = new Vector3(v.y, -v.x, v.z); break;
    }
    position = v;
    
more ▼

answered Jan 12, 2010 at 09:57 AM

duck gravatar image

duck ♦♦
47.3k 129 188 457

@Duck I'm really interested in this method, but I'm completely lost, could you point me some right direction, i have no idea what the code you provide is showing me, is it generating planes then curving them to create a sphere?

Nov 27, 2010 at 11:09 PM Caiuse

Wow. I haven't been back here for a while. I love your programmer solution Duck! Being an artist, it slid right over my pointy head. Ended up modeling it in Maya and doing a bunch of tricks to keep the poly count down.

Thanks!

Dec 03, 2010 at 03:53 AM spencer lindsay

I've been searching for something like this for about a week now with no luck. Is there any chance you could go into more detail on how to accomplish this or post a complete script? My game's at a standstill until I figure this out.

Dec 06, 2012 at 05:14 PM cwperkins83

hey any video tutorial about this ?

Jun 20, 2013 at 04:37 PM Calymore
(comments are locked)
10|3000 characters needed characters left

Just an idea without having tried it, but there's a blender plugin that turns a mesh into a solid wireframe. You could take a UV sphere as a guide, turn it to a solid wireframe, and then place terrain into the grid by hand. There's also Blender World Forge, which builds spherical "planets" of arbitrary sizes, but I haven't been able to get the results to look good yet. The noise options the plugin uses seems too regular for me.

more ▼

answered Jan 12, 2010 at 08:48 AM

Thoth1978 gravatar image

Thoth1978
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2337
x337
x12

asked: Nov 17, 2009 at 10:04 PM

Seen: 12925 times

Last Updated: Jun 20, 2013 at 04:37 PM