Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Spherical world gen using Experilous method  (Read 5792 times)

rdeforest

  • Escaped Lunatic
    • View Profile
Spherical world gen using Experilous method
« on: December 04, 2014, 07:35:25 am »

Motivations:
  • Plate tectonics could improve topological realism, add realistic mineral and volcano distribution and introduce earthquakes
  • Wind, temperature and moisture model provides more realistic weather patterns and biome placement
  • River and lake creation realism improvements
I recognize that realism is not the highest priority, but it is clearly of some importance given that the current engine models fluid, thermal and mechanical dynamics to the degree it does. I also assume it would be a monumental effort to modify Dwarf Fortress to use triangular or five to seven sided tiles, but there are mitigating factors. The spherical graph could still be dynamically mapped to a square grid and the mapping updated when the view moves a certain distance. Distortion would be minimal for small enough map areas. The algorithm is documented in the blog post. Source code is provided with an attribution license. Toady has a strong math background, so the hard parts would be the UI changes. Mifki's work on creating a network API would obviate the UI issue since the community could work on that.
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #1 on: December 04, 2014, 03:13:24 pm »

It's a hell of a lot easier to do a torus, if all you want is plate tectonics and weather patterns and stuff -- these things only require wraparoudn and curvature, not specifically SPHERICAL curvature. And toruses are much easier to do the math for and can still be displayed, unwrapped, as a rectangle for easy graphics.

See the link in my signature about a geologically realistic game world generator project for games like dwarf fortress that addresses exactly this sort of stuff! Currently developing slowly as I am writing my dissertation, but will pick up again soon. Will have plate tectonics working in a basic fashion within a month, probably.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Reelya

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #2 on: December 05, 2014, 11:19:56 am »

That's a terrible system for planet generation. I was all set to be amazed, but that wasn't very good. Tesselation with irregular polygons looks funky, but is useless for any real game.

Use Experilous method? It's a load of junk!

The better way is to use cube-mapping for the sphere. Effectively, then the sphere is modelled as 6 square maps arranged in a cube but morphed onto a sphere. One advantage is that most location mapping still only needs to logically work on a grid, so there is no need to rewrite large chunks of the code.

Cube mapping could also theoretically be used with existing dwarf fortress and something like Perfect World DF, where you use perlin noise to generate 6 faces of the cube map from a spherical data set, generate those as 6 regions in DF, then export all 6 and render them in OpenGL as a 3D DF "World" (even though, they're really 6 worlds, but the terrain should match up).

Spoiler (click to show/hide)

Here are some cube-mapped planets I made myself:
http://www.bay12forums.com/smf/index.php?topic=91670.0

Most of the downloads are dead, but I found a copy of the code and exe. Cool, I thought I'd lost this code because of a HD failure and my uploads got deleted. Somehow, they missed this one. Shame it wasn't the latest version :/
http://www.mediafire.com/download/vc7ygffzirpfu2p/planetgen.110825.rar

Feel free to play with this, and if anyone wants to make it into something else I will give help and assistance. I wrote every line of this code from scratch.
« Last Edit: December 05, 2014, 11:37:32 am by Reelya »
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #3 on: December 05, 2014, 12:37:29 pm »

That works too, definitely better than the weird polygon thing!

Still, we are talking about dwarf fortress here, not Spore. You aren't ever going to be looking at the planet as a whole in gameplay, so it really doesn't need to be a sphere.

If you wanted to make believeable continents to look at from orbit for a procedural space game, then the soccer ball polygons would be best, as long as you don't have to play on the super confusing grid that results.

If you want Spore where you're actually spinning the world around and building stuff on it and using the grid, then the cube mapping sounds best.

If you're only ever playing on a tiny patch that is interpreted as purely flat, though, like dwarf fortress (or minecraft, etc.), then you should just use whatever shape is absolutely most mathematically convenient to map to a flat rectangular system, and not worry about the headache of anything fancier.

Cause even with a cube, you have 8 distinct wrapping boundaries and much more confusing sets of arrays all over the place. Torus is 2 wrapping boundaries and one rectangular array of data. I'm pretty sure it's the simplest continuous curved surface for Cartesian math you can use:



Looks stupid if you ever need to look at the planet (IN SPACE. A map is fine and can just be a rectangle), yes, but if you don't, it makes the math a lot simpler.
« Last Edit: December 05, 2014, 12:39:55 pm by GavJ »
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Reelya

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #4 on: December 05, 2014, 09:57:47 pm »

For units moving over a cube-mapped sphere I just use a custom x/y object which also tracks which face you're on, it automatically handles travelling over and edge to another face so that the rest of the program only handles "loc" objects instead of x/y coords.

Cube mapping is still better than Experilous for realistic continents:

Spoiler (click to show/hide)

The image in the first post has unrealistically low density of tiles, that was just to illustrate the concept and not something you'd use in practice.

In my code I get best effects when each face is at least 32x32 squares, with 512x512 giving nice detailed results.
« Last Edit: December 05, 2014, 10:03:28 pm by Reelya »
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #5 on: December 05, 2014, 10:02:39 pm »

Eh? The ones from the firs link look a lot more realistic:
Spoiler (click to show/hide)

However, I don't think this really has much to do with the mapping for either of them. It has to do with good land generation and the guy's tectonics efforts, I think. It could probably be applied equally well to either mapping. So whatever, I guess they're both equally good potentially for showing images of planets from far away.

The only reason I think the cube one is better for a game is if you actually need to players to interact with a grid in the world, like if you were trying to apply it to dwarf fortress. Obviously a rectangle-ish grid is nicer to work with than a soccer ball. For pure aesthetics though I don't think it matters.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Reelya

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #6 on: December 05, 2014, 10:07:16 pm »

The reason for that was that I turned off all the water generation for my planets because I was trying to render large solar systems at once in realtime and you could fly from one solar system to another. Water and atmosphere layers added extra polys, so i cut those out to render more planetoids at once.

What you're looking at is my attempts to model "rocky" planets, which are more common in space. I have separate stuff for rendering Earth-like planets. But I don't want most of my planets looking like that.

These are some from a program I made back in 2002:
Spoiler (click to show/hide)

These are pretty old though, and before I started using OpenGL. I had some more recent screenshots of my opengl planets with oceans and atmospheres, but I seem to have lost them along with some other files.
« Last Edit: December 05, 2014, 10:16:51 pm by Reelya »
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #7 on: December 05, 2014, 11:07:10 pm »

The tectonics one still looks significantly more realistic to me, which looks to be Perlin noise. Mountains tend to hug the sides of landmasses not the middles, landmasses should occasionally form puzzle pieces with one another, deep portions of oceans form internal distinct lines and ridges that should also line up with continents, not blobs, coastlines that noisy would get worn down to a smoother shape very quickly, most islands tend to be pretty tall on the whole, at least many of them should be, and they tend to form chains, not shapeless clouds, etc.

But again, none of that has to do with the shape projection. I find your planets to be pretty impressive in that sense, insofar as I cannot detect any distortions at places where cubic seams might have been smashed in there.
« Last Edit: December 05, 2014, 11:08:42 pm by GavJ »
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Reelya

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #8 on: December 06, 2014, 04:03:37 am »

I could add the tectonics thing into my next project, there's no reason something like that can't be added into a cube-mapped model rather than a tesselation model. I did want some nice mountain ridges and modeling plates as an invisible sub-stratum is probably the way to do it.

Both systems are probably encoded exactly the same in many respects: 3D perlin noise intersecting with a sphere gives you your height-map. That's how you avoid "cubic seams" since the underlying height values are generated in 3D which has no innate connection to the cube/grid, the cube/grid is only the presentation layer, not the model.

For tectonics the approach I'd probably use is to plant some "plate seeds" in random locations and have those spread out semi-randomly until all the map is filled, this approach also gives realistic looking "country boundaries" if used to generate nations. Then, I'd give each plate a random movement vector, and where plates are pulling apart, lower the fractal terrain, and where crushing together, raise the fractal terrain. It looks like he also decides whether each plate is land or water before processing, that's also something that could be set as a parameter.
« Last Edit: December 06, 2014, 04:15:03 am by Reelya »
Logged

GavJ

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #9 on: December 06, 2014, 12:06:08 pm »

Sorry that was a typo "Which looks to NOT be Perlin noise" but rather something like what you wrote in your last paragraph. Don't need world-sized noise if doing tectonics. Only a bit to roughen up the surface, and you have randomness in plates, but the height is from the dynamics.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Symmetry

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #10 on: December 07, 2014, 08:46:54 pm »

It's really nice to see an example of a plate tectonic procedural generator.  It's discussed online but I couldn't find example source code last time I went looking.
It really needs rivers though, that's the one bit missing.
Logged

Neonivek

  • Bay Watcher
    • View Profile
Re: Spherical world gen using Experilous method
« Reply #11 on: December 09, 2014, 09:58:15 pm »

All this really means is...

DANG do I wish more games used cool systems... and Dang do I wish they started making Spore 2: The Good one.
Logged