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.


more ▼

asked Nov 17, 2009 at 10:04 PM

avatar image

spencer lindsay
222 19 19 38

(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

avatar image

66 1 1 4

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

    avatar image

    duck ♦♦
    51.5k 147 417 546

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


    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

    alt text

    Hey All,

    Had the same problem as described so I went with building my own mesh. I started with a 6 sided cube mesh made in Rhino. I used the Grasshopper plugin to sample height-map values and added the vector amount to each UV on the cube respectively. The result is pretty good but very heavy, which leds into a L.O.D. (level of detail) issue. Not to mention having to code in planetary gravity and player controllers. IE... Planets are custom Assets as far as terrain is concerned. Took me a couple of weeks to figure out 'my' work-around for planet making and I'm still not done. ... never done.. best practice guild for planet creation needed...

    planetexample.jpg (135.5 kB)
    more ▼

    answered Feb 21 at 11:27 PM

    avatar image

    1 2

    (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 and Comments



    asked: Nov 17, 2009 at 10:04 PM

    Seen: 16695 times

    Last Updated: Feb 21 at 11:20 PM