any way to use Terrain inside a giant cylinder?

I’ve started prototyping the “inside colony” mode for High Frontier (see video here). So, instead of being based on a flat plane, my world is wrapped around the inside of a giant cylinder (or other closed shape).

Placing buildings, trees, vehicles, etc. on the inside of this cylinder is easy enough, as is making a perfectly flat ground (just a giant cylindrical mesh, facing in). That perfectly uniform ground is boring, though. I’d love to use Unity’s Terrain system, but how?

I had hoped the Terrain component generated a Mesh which I could then manipulate the vertices of, to bend them around into a cylindrical shape. But nope, there doesn’t appear to be a mesh filter at all, or any access to the vertices it must be creating under the hood. When I think about it, I guess that makes sense; it’s probably dynamically adjusting the level of detail, perhaps directly stuffing things into the rendering pipeline, rather than inserting meshes into the scene graph.

But I really love the Terrain editor for its easy of sculpting and painting the terrain.

Anybody have any ideas how I can make use of Terrain with a non-flat (e.g. cylindrical) geometry? Or if that’s impossible, some similar tool that would work?

Thanks,

  • Joe

You can modify the vertices indeed: Seamless tiled infinite terrain: simple script for easy fix of seams and edit - Unity Engine - Unity Discussions

SetHeights only lets you set the relative Y position of the terrain. That’s not enough to morph the overall terrain shape (say, into a cylindrical shape).

Terrain definitely cant be molded into a cylinder shape. Ive not looked at assets that might do the job, but I suspect you might have to roll your own since yours is effectively backwards from what most would provide… maybe theres a good caving plugin you can use.

interesting looking game btw.

Yep.

–Eric

I think this is an interesting idea!

One way would be to keep a normal flat terrain and use the terrain editor to make the kinds of hills/mountains/features you want.

You would do this keeping in mind that one axis in the terrain (north south) would map to the cylinder’s length, and the orthogonal axis would map to the cylinder’s circumference.

When you are done with the terrain editor, export the heightmap (from the settings pane I think in the terrain editor?) information. Then write a little tool to read those heights into something you can pull into Unity (it will be a 2D array, I believe of integers, but don’t quote me on that.).

Now create a perfect blank cylinder like you have done, faces pointing inwards, and with enough subdivisions to match the size of the terrain you want, the dimensions of the exported heightmap.

Alternatively you can just iterate the contents of the 2D heightmap array and fabricate the entire cylinder in Unity (look up making procedural geometry) at runtime.

Now, using the individual cells of the exported heightmap, “bring in” each corresponding vertex of the cylinder, so the mountains bump inwards, the valleys curve outwards. You would bring it into the direction of the central axis of the cylinder. Vertices would not move along the axis of the cylinder at all, only inwards and outwards according to heightmap.

Now this won’t get you the nice texture painting features that the Unity terrain editor gives you, but it is a start.

If you took a top-down snapshot of the terrain all once it was “painted,” then you could UV-map that large bitmap onto the interior of your lumpy cylinder.

You could even use the heightmap data to “move inwards” any houses and/or other buildings that you had previously “stuck to the inside of” the perfectly flat cylinder, which would get them at least close to where they need to be.

It’s a bit of a kludge, but it would be workable for a quick test.

Kurt

Yeah, something like that sounds like what I’ll have to do. I’m already generating the cylinder procedurally, but currently it only has vertices at the ends. I’ll need to generate a much higher-resolution mesh (or, probably better, series of meshes so they can be culled) to represent terrain.

Using the terrain editor to paint the elevation and texture map, and then just reading the data, is an interesting idea. I might even load the terrain, and just not render it, but use its GetHeights method to give me the grid of heights I need to adjust my mesh.

However, ultimately I guess the sculpting of the terrain will be up to the player… so hooking into the terrain editor is probably wasted effort.

Anyway, it’s helpful to know that I haven’t missed some easy trick. Thanks, guys!

I was thinking to assemble many terrain each one procedurally curved to form the final cylynder.

Ah, like a series of long strips, like barrel staves?

I just did some tinkering with a Unity terrain object in a scene and it does not look like you can rotate or tilt a terrain object.

Reading this thread seems to confirm this:

Kurt

You are right… :frowning:
I was taking that for sure because you can translate it… but it can’t rotate.