Jump to content
  • Advertisement
  • entries
    19
  • comments
    25
  • views
    11095

Planet Generation Plans

nukomod

1596 views

 

Hey all!

This time I'm going to write a little about my plans for generating planets. This entry won’t go into any specific details of the terrain generation but will be just a very high level overview of the basic framework. I don't think any of the ideas in here are new.. the procedural generation community are a very clever bunch indeed! I'm always amazed how when an idea pops into my head I'm able to find an existing article about it that goes into fine detail on the subject. Anyway let's crack on!

Heightmaps & Voxels

When it comes to generating terrain an easy first choice is to generate height maps and build the terrain mesh from that. You can get some good looking results quickly by overlaying some noise generation and tweaking things here and there.

image3.jpg.d0643950ffdd9f86dd0f6e1020922ba8.jpg

Though these can give some nice results they have limitations. For example tunnels and overhanging terrain can’t be represented in a simple height map. You also have to choose a projection scheme to map a 2D height map onto a sphere.

image2.jpg.4f5a2e118dcbb0837f584cfc2e21d34d.jpg

There’s another approach to terrain generation using voxels and that’s what I’m aiming to use. With voxels you can define all sorts of complex terrain and you can define what’s hiding under the ground too - whether it's seams of coal, ore or underground rivers. Many games use voxel terrains to great effect such as the infamous Minecraft. Sign me up!

In Minecraft the voxels are arranged in a grid, keeping everything nice and simple.. until you want to model a whole planet. Then you’d get something like this:

image4.jpg.06803f5afaa2b9138cb96c5e1150a331.jpg

Though that does look really cool, I don’t want my worlds to be great big cubes floating in space, so what do I do? There are all sorts of solutions to building a spherical world from a voxel grid, but they seem to be full of difficult space warping, caveats and rendering complications. I’d rather not deal with these kinds of complications, so I’m going to try a different approach.

Instead of arranging the voxels in a grid I’m planning to arrange them as points on a geodesic sphere like this (imagine the vertices are voxel points):

image9.jpg.0446fca9ecb9619023c5af59509a80be.jpg

It’s like taking the space warping issues you’d need to do at the cubes edges and spreading it evenly across the entire surface of the sphere. Instead of it becoming a difficult edge case it becomes a constant low level annoyance and keeps things consistent at all times. It will make the mesh generation a little more fun later too ;)

Voxel Planet Generation

The plan is to use an icosahedron as a starting point. Each vertex here is a voxel. This can be considered the lowest possible Level Of Detail (LOD) of a planet.


image1.jpg.a202d4363bdf2de698a27ea7eebeadd1.jpg

The space is chopped up into tetrahedrons from the planet surface into its core. There is an extra vertex at the centre of the planet for this.

image7.jpg.8681f66211b5b6385177bcae6a15e424.jpgimage8.gif.257e47a37cb70829e3a746f664e40150.gif

These tetrahedrons can be subdivided through to the core of the planet as required.

image5.png.87fe7726c2411700a7f6d0545558fae7.png

These illustrations are somewhat misleading though as this isn’t just generating a spherical mesh, but a bunch of voxels that could be empty space. The voxel points (vertices) hold information about what's actually in the space they occupy, whether it’s atmosphere, rock, magma etc. It is the job of the terrain generator to define what a voxel contains. I'm going to keep a clear divide between the planet voxel generation code and the terrain generation code this way.

I have some uncertainties on how to best manage the subdivisions of the planets voxels as required, but I’ll bash it out in a prototype.

Dynamic Changes

The game also needs to be able to make permanent changes to the terrain during play. Large explosions should create craters and I want them to persist. To do this I will need to be address the voxels and save state changes about them. I'm not 100% sure on the approach for this yet either. One train of thought is to basically create an algorithm for the voxel generation that that is able to assign each possibly generated vertex a unique 64bit number. That would have no waste and allow the maximum number of voxels, and some napkin math makes me believe it would have good detail on earth sized planets. Another approach could be some kind of hash of their XYZ or polar coordinates, though that will be more wasteful so it’d bring the total addressable voxels way below what a 64bit unique id could theoretically hold.

Ok that’s enough for now!
 

 

 

 



17 Comments


Recommended Comments

I've had some success applying the usual cube-> sphere transformations to a cube where each face is a voxel shell with some pre-determined thickness. It's not terribly elegant, but it's easy to get up and running. Your tetrahedral approach might avoid some of the distortion and apparent grid - interested to see how it turns out.

Share this comment


Link to comment

Very interesting.  I'll be curious to see how you realise the plan.

Share this comment


Link to comment

Looks neat. In fact I'm working on almost the exact same thing :)  However I'm not sure you can divide tetrahedrons evenly. You can get four new ones on the corners and then you get this sort of odd center space.  In your picture it looks to me like you divided up the faces of the original tetrahedrons which you can do easily, however chopping up the insides might be tricky, however if you figure out a good way to do it, it would be way cool.

I decided to use prisms, just because you can make an octree out of them like you can a cube.  The down side is you can't go all the way to the center of your sphere and also the inner ones are a bit smaller than the outer ones. But if you build your geometry around some reasonable band of the world it shouldn't be a huge problem, and also it gets rid of the problem of geometry looking different in different corners of the world like you would get if you generated your world in a simple subdivided cube.

I had an old version working a few years back but it just used height-maps applied to a subdivided icosahedron based simplex-noise. However it did let you walk around a huge planet without generating any data in advance.

Share this comment


Link to comment
19 minutes ago, Gnollrunner said:

However I'm not sure you can divide tetrahedrons evenly. You can get four new ones on the corners and then you get this sort of odd center space.

That odd sort of space in the centre is an octahedron. Decomposing the octahedorn is tricky, but not impossible

Share this comment


Link to comment
1 hour ago, swiftcoder said:

That odd sort of space in the centre is an octahedron. Decomposing the octahedorn is tricky, but not impossible

Somehow the prisms still seem simpler to deal with though.

Share this comment


Link to comment

You guys are spot on about dividing up the space. I didn't realise at first that tetrahedrons don't tessellate in 3D space, it would have been great if they did. The picture of the sphere where you can see inside is quite misleading isn't it! Gnollrunner I'm playing with some options now, which includes some with prisms, seems I may be going down the same route you did :) Do you have any links related to what you did?

Share this comment


Link to comment
1 hour ago, nukomod said:

You guys are spot on about dividing up the space. I didn't realise at first that tetrahedrons don't tessellate in 3D space, it would have been great if they did. The picture of the sphere where you can see inside is quite misleading isn't it! Gnollrunner I'm playing with some options now, which includes some with prisms, seems I may be going down the same route you did :) Do you have any links related to what you did?

I really don't, I'm just kind of winging it.  I'm basically doing the same thing as marching cubes except with prisms. The hard part is really the LOD transitions.  I think surface nets or dual contouring does that better but then you get other issues you need to deal with. I haven't found any magic bullets. I'm using octrees with chunking such that all cells in a chunk that have any geometry must be at the same level AND neighboring chunks can at most have one level difference. Even with that, the edge conditions are a pain. I worked out an algorithm that seems to work but I'm still debugging all the cases. I have table look ups with pointers to little subroutines that handle various cases. It's a lot of code, but I'm tying to avoid a lot of ifs.

Share this comment


Link to comment
On 6/19/2018 at 6:03 PM, nukomod said:

You guys are spot on about dividing up the space. I didn't realise at first that tetrahedrons don't tessellate in 3D space, it would have been great if they did. The picture of the sphere where you can see inside is quite misleading isn't it! Gnollrunner I'm playing with some options now, which includes some with prisms, seems I may be going down the same route you did :) Do you have any links related to what you did?

Yeah, I was doing the same kind of problem (I started with an octohedron, but...) and found the same problem. I don't have my notes at the moment, but I seem to remember splitting lengths into three (or maybe four?) rather than two and thus getting a vertex in the center, which IIRC solved it. Maybe you can experiment along those lines, I'd love to know what you end up with in either case!

Share this comment


Link to comment

You could consider an more complex cube->sphere thingy, similar to the results a hexahedral meshing algorithm would produce, see this image on the left. The only advancement is that the interior does not tesselate to infinity, if you want destruction of whole planets for example. Increasing scale issue on the surface remains the same.

 1-s2.0-S0378475414000871-gr14.jpg

Share this comment


Link to comment
5 hours ago, JoeJ said:

You could consider an more complex cube->sphere thingy, similar to the results a hexahedral meshing algorithm would produce, see this image on the left. The only advancement is that the interior does not tesselate to infinity, if you want destruction of whole planets for example. Increasing scale issue on the surface remains the same.

 1-s2.0-S0378475414000871-gr14.jpg

The first one looks similar to what I'm doing, except you start out with a cube so you end up with hexahedrons instead of prisms. In my case I won't have destruction of whole planets (no Death Star in my game :P) so I don't worry about the middle. You can easily use marching cubs, surface nets etc with this, but you sill have the same issues of LOD transition, chunking and so forth which in my experience is the hardest part.

I think if I wanted to support full destruction I might be tempted to just forget about tying the make voxel orientation uniform around the world and just build everything with regular matrix.

Share this comment


Link to comment
JoeJ

Posted (edited)

Thinking of it my proposal is pretty stupid - using a simple subdividing cube grid projected to sphere has the same advantages at the core and the same number of singularities at the surface. (Ooops :) )

 

Edit: But there may be advantages to support Minecraft alike building eventually? Not sure - my world looks flat if i look outside the window and i'm happy with that :)

Edited by JoeJ

Share this comment


Link to comment

Just got a look at my old handwritten notes (dear lord in heaven....). I completely forgot that I started experimenting on something you miiiight have a use for. Basically, treating existing objects as point clouds and converting anything near the player to visible graphics via a standard marching cubes algorithm. If there are a lot of gold points in a section, that section is depicted as a gold thingie, and so on.

Just a thought. I'll go into my padded cell now and count the silence.....

Share this comment


Link to comment

as far as topology goes one method I've found that looks sort of neat is as follows:

1. create a random line (for sphere, hemisphere), random side of the line raise +1, other side of line -1.
2. repeat procecess until desired shape is achieved. (100-1000+)

 Problem with this though is that sometimes it leads to really unround, lopsided planets sometimes. Other than that it can look pretty dynamic. I did not come up with this idea, though, and I don't remember where I got it. Also may need to smooth or scale.

Edited by h8CplusplusGuru

Share this comment


Link to comment
4 hours ago, h8CplusplusGuru said:

that looks like it exactly 😃

I implemented this years ago. The main problem I have with it is, it doesn't easily let you just generate local terrain at one point on the planet.  While it's procedural, you end up having to store everything rather than just keeping the stuff you need that's around the camera.  For me simplex noise works a lot better since you can easily throw away and regenerate local data as needed to whatever level you want, and also you can customize your functions locally in infinite ways. 

I suppose you could use it as a base function for which you store your terrain at a predetermined level and then apply simplex-nose stuff on top of it to fill in the details.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By GreenGodDiary
      Sup dudes and dudettes!
      I'm in the process of implementing an animation state machine and am currently making a 2D blendspace state for it.
      I think I've figured out how to blend the different clips together given an [x,y] coordinate but I have one problem I'm not sure how to solve; matching the different blended clips' animation speed.

      Say you have your run-o-the-mill twin-stick character locomotion blendspace, where max Y, zero X means running straight forward, and max Y, max X (in either direction) means running at an angle (thus blending run_forward with run_strafe).
      In this case the animations' speed probably match, so there's no worry. However, say I'm halfway up Y, meaning I'm "jogging", in the sense I'm halfway between walk_forward and run_forward, and my X is at some arbitrary point.
      How would I blend these animations together so that their speeds match? Would it be as simple as 'lerping' the animation speed of the walk towards the speed of the run and scaling the speeds of all the clips to match this speed?

      Sorry if the question is poorly written.
       
    • By FlyX
      Hey Gamedev.net Community!
      I am working on a mobile builder game that's already running for 8 years.
      In its early days, the game had a nice content progression until level 30(current max level is 140). With content progression, I mean at what level items unlock in the build menu. However, over the last ~4 years, the previous developer decided to unlock all the content between lvl 1 and level 30 (reasoning that the new content should be available for all players). This results in 1200 ~available items at level 1 and ~3300 items at level 30. Overwhelming players at the start and missing any content progression after level 30(can be reached within a few weeks, while a big part of the community is playing since multiple years).
      But how should this be addressed in a running game with a considerable user base across all levels?
      Internally we have a passionate discussion between moving existing items to later levels(and risking to anger existing players) or just adding new content to later levels(don't address the too much choice issue at the start)
      Since we are kinda stuck in the discussion, it would be nice to hear some external input
      Thanks!
    • By Septopus
      Well, here goes.  I'm currently developing a game whose core economy is based on an approximation/simulation of the actual periodic table of elements(the first 92 or so).  Essentially the player is using a future technology(future setting) to mine pure elemental resources from the planet without harming the ecosystem/terrain.  Think Star Trek type tech.
      The game is multi-player online(not online yet, still in lab), design goals are aiming for MMO.
      I'm currently at the problem of Currency.
      My design parameters are such:
      At Server Start, the game will have a fixed amount of each of the 1-92 elemental resources distributed in global resource deposits that are recoverable using the tech available to the players.  Resources amounts will be balanced so they meet the requirements of the games crafting system/etc. as well as attempting to match a rough approximation of a feasibly naturally occurring system. These fixed resources and the things they get turned into are to be the entirety of the "Matter" that is required for input(trade goods, crafting ingredients,etc.) in game play activities. All Crafted Items can be converted back into useful elemental matter through Recovery processes. Lost matter(Recovery is not always 100%) will develop new resource deposits, or add to old ones that have not been discovered yet. Discovered Resource deposits must be exhaustible. The problem arises when I begin conceptualizing a market system, and most specifically an Auction system. 
      I come to the conundrum..  How do I setup a starting bid amount or even a bidding system without a specific currency?
      Do I choose a specific element, say grams of Gold, as THE currency?
      Do I generate some code that tells the players that they have items in their inventory that are worth more than the current bid of 20kg of Iron, according to the current market conditions on the trading platform?
      Do I do both of these things?
      Do I need a more abstract form of currency to make it more (but less) tangible to the players?
      (not my favorite, but) Dollars, Coins, Gems?  Something totally abstract that cannot be mined or crafted?
       
      I'm trying to attack this conundrum from a "how would a player like it to work?" perspective..  But I'm stalled a bit.  Any insights/experiences/thoughts would be appreciated.
       
      Thanks in advance!
    • By william.equal
      Hey, I just finished a new episode of "Game Audio Lookout"! This time it's about musical sound effects in the Super Mario series. Here's the link to the video on YouTube:
      --
      Musical Sound Effects in the Super Mario Series | Game Audio Lookout
      https://www.youtube.com/watch?v=6hHbTVloizU
      We’ll have a deeper look at musical sound effects in the Super Mario series in this episode of "Game Audio Lookout".
      I guess everybody has heard the sounds of the Super Mario series before. But I believe most of us don’t exactly know how these were constructed and what efforts were taken in later instalments of the series to produce sound effects that even harmonise with the game’s music.
      --
      Feel free to let me know what you think
      Alex
    • By gdarchive
      Intro
      Due to my belief in learning through self-discovery and my ongoing creative evolution, I've long put off doing any tutorials. However, after making pixel art for over 3 years I've established many solid techniques worth laying out in a concrete fashion. While I'm excited by the prospect of helping others with my experience, I still urge artists to explore things their own way. The wonderful thing about art is the unlimited number of solutions to a problem. I offer you solutions that have worked for me and I hope they work for you, but I will be even more thrilled if you discover a better solution along the way.

       
      When it comes to pixel art, it all starts with a good color palette. Creating a custom color palette can be a very satisfying and powerful way to establish your own unique look. I'll guide you through my method as I create a new palette. But first, let's go over some basic principals.
       
      It's all about HSB
      I find it easiest to understand and control color through HSB.
      Hue - The actual color (0 - 360º)
      Saturation - The intensity or purity of a color (0 - 100%)
      Brightness - The amount of black or white mixed with a color (0 - 100%)
      By understanding and adjusting these 3 fundamental properties you can create custom colors with precise control. I recommend this article by Steven Bradley for more detailed definitions of HSB.
       
      Color Ramps
      A color ramp is a specific range of colors that work well together, arranged according to brightness. Here is an example of what I consider a good color ramp. 

       
      Brightness steadily increases from left to right in this example. As the colors reach high brightness levels it's important to decrease saturation, or you'll end up with intense eye burning colors. Also, colors with very low brightness can become overly rich and weighty with high saturation. Saturation peaks in the middle swatch in this example.  
      A good color ramp should also apply hue-shifting, which is a transition in hue across the color ramp. In the previous example the hue is shifting by positive degrees as the brightness increases. 
      Many beginners overlook hue-shifting and end up with 'straight ramps' that only transition brightness and saturation. There is no law that says you can't do this but the resulting colors will lack interest and be difficult to harmonize with ramps of a different hue. This only makes sense to me if you want a monochromatic look and stick to one straight ramp.
       
      The Palette
      A color ramp is essentially a palette, but most palettes contain multiple ramps. I like to create large palettes with lots of ramps, which I can then pull smaller palettes from per assignment. 
      Mondo  - 128 colors

      Become a Pixel Insider member and download Mondo
       
      I took the opportunity to make a brand new palette for this tutorial. My intention was to create a general purpose palette that strikes a balance between vibrant colors and desaturated natural colors. So, how to make such a large palette?
      First I decide how many swatches I want per ramp and how many degrees of hue shift. For this palette I want 9 swatches per ramp with 20 degrees of positive hue shift between each swatch. I like a lot of hue shift because it creates harmony between ramps and just looks neat, but 20 is about as high as I go.

      The color picker panel in Photoshop. We only need to be concerned with adjusting HSB.
       
      I use Photoshop, but a similar color picker panel should be accessible in just about any graphics software. To start I pick a color that will fit right in the the middle of a ramp. The hue is somewhat arbitrary, but the saturation and brightness is critical. I want the middle color to be be the most vibrant so I set the saturation and hue to the max combined number I'm willing to go.

       
      After I've chosen my first color I can set the hue for the remaining swatches based on the positive 20 degree shift I wanted. I could reverse the direction of hue shift if I want but positive hue shift usually results in more natural colors, warming as they become brighter. 
      I still need to sort out the increments for S&B. Unlike hue, shifting the S&B in uniform increments doesn't necessarily produce satisfactory results. However, there are a few tendencies I follow. Brightness consistently increases from left to right and usually never starts at 0, unless I want black. Saturation peaks around the middle and never fully goes to 100, or 0. The goal in mind is to create even contrast between each color.

       
      After some tuning and eyeballing these are my final values and resulting color ramp. The hue shift looks pretty strong but it will make sense when I add more ramps.

       
      This version shows the difference in the increments. Pay attention to what the S&B are doing. You can see there is some consistency in the pattern. The saturation takes larger steps on the ends and smaller steps in the middle where it's the highest percentage. The brightness takes smaller steps as it gets closer to the end at full 100%.

       
      Here's another visualization that clearly shows the flow of S&B as line graphs. You don't have to follow this general flow of S&B. It just depends what look you're going for. I've made ramps where the saturation continues to climb as the brightness decreases, creating an X pattern. This results in vivid dark colors. The biggest mistake is combining high saturation and brightness, unless you want to burn some eyeballs. I recommend a lot of experimentation with the HSB values of your ramp. I've tried to come up with mathematically precise formulas but it always seems to come down to trusting the eyeballs to some extent.  
      Now let's finish the palette.

       
      Up to this point all I have been doing is picking colors and drawing them as single pixel dots on a tiny canvas. I haven't actually added any swatches into the swatch panel. With the first ramp established all I have to do to create more ramps for my palette is shift the entire set of hues.
       

       
      I want 8 ramps total so I will shift the hues of each ramp by 45 degrees to complete the 360 degree cycle around the color wheel. I could do this in the color picker by adjusting the H value one color at a time, but In Photoshop I can save a lot of time by duplicating the ramp and changing the hue of the entire selection (Image-Adjustments-hue/saturation, or ⌘+U).

       
      After adjusting the hue of all my color ramps my palette appears like this. It looks pretty nice but It's lacking more neutral desaturated colors.

       
      To add desaturated colors I duplicate the whole middle section of the palette, omitting only the darkest and lightest colors on the ends, flip it over and desaturate them with the Hue/Saturation panel. I omit the light and dark columns because they appear nearly the same as the originals. I flip the colors because it makes for easy navigation, and it looks cool. The desaturated colors can provide a more natural look, and work well as grays in combination with the vibrant colors.

       
      The final task is actually adding the colors into the swatch panel. With the color picker panel open I sample each color with the eyedropper and click the 'Add to Swatches' button. I add them from left to right, top to bottom so they will appear in the swatch panel in the correct order. This is quite tedious but the only way I know of to add the colors in the particular order I want. 

       
      Once I've added all the colors into the swatch panel I click on the panel options and make sure to save my palette. I can then easily load the palette as a .aco file into the swatch panel anytime. Also, by selecting 'Save Swatches for Exchange' you can create a .ase file, which can be loaded into several other Adobe programs. Save the image of your palette as a .png file and you can load it into Aseprite.   
      Well, that completes my 128 color palette - Mondo. Now let's look at how I use the palette with some examples. 
       
      Picking Colors

       
      This example keeps it pretty simple, mostly relying on horizontal ramps of adjacent colors. You can also see how the warm desaturated colors work nicely with the vivid hues. I've added white into palette for extra contrast. 
       

       
      This example shows how ramps can move horizontally and diagonally. Because of the hue shift every color is surrounded by colors that can work together.
       

       
      Harmony is everywhere, just pick and play!
       

       
      This example uses complimentary color in combination with neutrals. The result captures an ominous yet hopeful feeling that perfectly fits the mood I wanted. 
      Picking colors for your art always requires some good sense, but a versatile palette with criss-crossing ramps like this makes it much easier. A little color goes a long way with pixel art, as you can see I never use a lot of colors for any one image.
      Creating a palette with this method also works great for game art, and will ensure everything in your game has consistent colors. I used this method to create a 160 color palette for Thyrian Defenders. We've been able to depict an incredible range of environments and characters while maintaining a consistent look overall. Other aesthetic choices come into play, but color is the fundamental ingredient that ties everything together.  
       
      Final Word
      Overall I'm quite happy with how this palette turned out. I think you'll be seeing more of my work in the Mondo palette from now on!
      I hope this helps you come up with some palettes of your own. I know It can take a bit of time to get a feel for HSB, but even if you're a beginner I think making palettes like this is a great way to understand color. Go crazy with HSB and don't be afraid to experiment with formulas that look different than my example. Also, you don't have to make such a large palette. Start with trying to make a small ramp.
       
      About The Author
      Raymond Schlitter (Slynyrd) is a former graphic designer who turned his creative passion to pixel art and game design in early 2015. Now he shares his knowledge with tutorials while he continues to make fantastic art and work on games. Support him on Patreon and get the inside scoop on his latest work.
       
      Note: This post was originally published on Raymond's blog, and is reproduced here with kind permission from the author.  If you enjoyed this article please consider supporting Raymond on Patreon, where he provides backers with exclusive downloads such the Mondo palette as .aco, .ase, and .png files. Get Mondo!  You can also make a one time donation to the author if you prefer not to subscribe on Patreon.
      [Wayback Machine Archive]
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!