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.
Answer by screenhogdotcom
Nov 18, 2009 at 12:50 AM
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.
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.
That's not really feasible, sorry.
You should just model the planet as a normal mesh. And setup your own radial gravity :]
Answer by duck
Jan 12, 2010 at 09:57 AM
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:
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 *= yi;
// rotate according to 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;
@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?
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.
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.
hey any video tutorial about this ?
Answer by ristophonics
Feb 21 at 11:27 PM
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...
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
3 People are following this question.
Unity 4 - Sphere Falls through Terrain
Perlin noise sphere
Sphere world real-time terrain alteration (a la 'populous 3')?
stitch spheriphied terrain-like (6) planes (removing gaps from edges)
Generating Heightmaps for a Spherical Terrain