2D planet generation

Hi, so I’m wanting to create a game like the mobile game, spaceflight simulator by team curiosity. What are your recommendations for 2d planet generation, gravity, and atmospheric effect? Any responses to help me get started would be greatly appreciated. I’m brand new game development, but I’ve been doing web development for 9 months and app development for 6 months.

I just learned about two important features for responsiveness, canvas scaler and anchoring in RectTransform comoponent.

Get to work and try lots and lots of stuff.

Procedural generation is not a thing you get better at by reading, because human language is nowhere near precise or accurate enough.

Just deciding what exactly it will be made up (sprites? geometry? texture pixels? something else?) will consume a significant fraction of your mindspace, and that is entirely dependent on what you want to accomplish.

Work in source control because you WILL make mistakes and screw up what you already have working. That’s true with all development and 10x true with procgen.

My MakeGeo repo has a smattering of random procgen stuff if you care to look around it.

MakeGeo is presently hosted at these locations:

1 Like

I’ve tried making a sprite big, but I encounter a big pixalized problem on the surface. But thank you, I’ll look into these three sources.

Then because making games like this is a big jump for me and a huge learning curve (I need to learn planet generation, thrust, atsmospheric reentry, gravity, orbits, etc), I’ve decided to first make smaller games focusing on each individual skill. For example, I would make a small game soacifically to focus on gravity. That way it seems less daunting and allows me to learn the skill.

This is a GREAT idea. If you love Lunar Lander or Asteroid-style games, these are super-simple things to start with.

If you want a jumping-off point, check out my SpaceShip2D scene in the Proximity Buttons game. It’s the core stuff for a Gravitar / Asteroids / Lunar Lander type setup.

proximity_buttons is presently hosted at these locations:

1 Like

Thank you for your replies. This is how I’m spending my summer.

AWESOME!!! Please do come back regularly and post updates… I forget what the tag is now, it’s like showcase or work in progress or something.

ALSO: use source control so you don’t lose your precious work. git is free.

ALSO: don’t get discouraged… gamedev is a long crazy road. If you ever need advice, just ask yourself, “Can I … ?” and try something… ANYTHING. It really works.

Like this guy does (talk about an inspiring video):

Imphenzia: How Did I Learn To Make Games:

1 Like

If you want me to update you, I can. I made a Tetris game on JavaScript Canvas following a step by step tutorial if you’d like to check it out (Basic Tetris HTML Game). I’ve made this and a gem catcher game on the Godot game engine. The gem catcher game was made following a video tutorial on Udemy. I unfortunately can’t share it because I deleted it.

I know what version control with Git is, it’s integrated in Visual Studio Code and I know Unity has one to, just have no idea how to use it. Never bothered to learn.

I have an app and website currently that I taught myself how to build. Getting from web development to app development was a little steep learning curve. Getting from app development to game development is also a learning curve I noticed. I started off with Unity with C#, then moved to Godot with GdScript, now I’m back with Unity. So not only am I trying to learn, I’m still deciding on what platform I want to build on. I like Unity and Godot for their own separate reasons.

This is quite in interesting video, thank you for sharing it. It’s a great reference video. I’ve also discovered Unity discussions a few days ago and I’m glad I did. The last 9 months of computer programming, I’ve been almost alone with YouTube and the internet teaching myself how to code. I was successful, but there were only three people I knew who could help me with web development and I was basically alone with app development.

Not many people know how to program which is sad because I was able to publish a website within a month and an app within 5 months.

The biggest problem I’m facing with 2d planet generation is pixel problems. That’s the largest barrier I’m facing with game development for me.

I can’t do sprites because they lose quite a large amount of resolution when you scale them up. I’m not sure if Unity has a solution for that. I have no idea what Geometry is or what texture pixels are. What I’ve been doing was making the planets in Affinity Designer 2 and exporting them as images. Although better than what I did at the beginning, they still lose resolution when I scale them up.

The most frustrating part about this is my lack on knowledge on potential resources. I’m not sure where to look for solutions. I emailed the creators of Spaceflight Simulator and Juno: New Origins, nothing so far. What I’ve been seeing on YouTube is either 3D planets (which is not what I’m doing), or 2D planets, but not proportionally scaled like I need them to be. When I search up 2D planet generation on the internet, this topic that I created shows up on the top of search results.

I’m getting discouraged because I don’t know where to look, but I’m still looking currently. I do see that you have 21 games published on Google Play.

Unity3D isn’t really a pixel engine.

Yes, you can manipulate pixels in Unity3D but it isn’t intended to be used for more than a few boutique low-performance uses.

If you want to manipulate pixels at scale in Unity3D, you pretty much have to code all that pixel manipulation yourself, sort of like we did in the 1980s writing pixel driver engines.

I would not consider this a newbie / beginner task, unless you’re talking dots chasing each other. Fabricating pixel art at scale from procedural code is not going to be straightforward, at least if you want it to be performant.

Another way is to do it in native C / C++ code as a plugin under Unity, which is how I did all of my KurtMaster2D games, which have native C code that prepares a Color[] array of pixels and gives them back to Unity to shovel into a Texture2D and present.

Where’d you get Unity 3D? I’m working with 2D right now. Anyway, I’m slowly making more progress now.

There is no Unity2D.

There is only Unity3D.

You can do 2D things in Unity3D.

Oh, okay. I’ve found a concept called procedural planets using Line Renderer and Mesh Components.

Here is the progress I’ve made so far.

Nice!! That looks like perlin noise applied to control the radius going around, if I had to put a bet on it. :slight_smile:

I thought more about your questions about pixels and procedural generation stuff… one way to make lots of pixels fast is to composite other images (such as an image of the geometry you generated above) on top of itself again and again using RenderTextures.

The elevator pitch for RenderTextures is that they function like Polaroid camera images that can “photograph” something in your scene and let you show it or use it somewhere else.

Here’s a lotto scratcher:

It is Perlin noise, how’d you know? I’m guessing how the planet looks in uniquely to that then. This is major progress for me though, trying to find out how to do this has been a major barrier for me. Game development is hard to learn though, I can see why people just don’t do it.

There is one thing I need to figure out though. When I zoom in on the planet, it looks flat, which makes sense because the terrain is done on a large scale. I still have to figure out how to make the terrain generate on a small scale. So that way it looks smooth when you zoom out and you can see the terrain when zoomed in. Here are some reference images for what I’m talking about. They’re not great images, but they get my point across I fee like.


I suggest I have to play around with these blocks of code I have. To my understanding, the segments control how many points are on the line. Increasing that makes it smoother.
BaseRadius decide how large the circle is, from the center to the outer point.
noiseScale control how large the uneven terrain is while noiseAmplitude affect the frequency. In other words, how close together each hill of terrain. I’m sure you already know, I just wanted to summarize because it helps me remember.

public int segments = 1000;
public float baseRadius = 50f;
public float noiseScale = 4f;
public float noiseAmplitude = 0.05f;

Game development is applied math and applied logic and a huge splash of artistic endeavor blended in just right… I find it irresistable and spend about 100% of my waking hours thinking about how to model different game effects, then I go to Unity and try and pull it off. So fun.

AHA! Now you’re onto the magic sauce: blending octaves of noise.

If you think of perlin noise having an average frequency, by adjusting the rate at which you traverse the input domain, you adjust the effective output frequency.

By blending bands of frequencies, at different amplitudes, it’s amazing what you can get.

I literally just solved my problem and got what I wanted. I just had to increase the noise scale and decrease the noise amplitude. Noise amplitude controls how high the hills go while noise scale controls how frequent or close together they are.

You don’t see the terrain when zoomed out, but do when zoomed in. The hills are also not too high, exactly what I wanted. One thing I like about coding is when you solve big problem, you get a massive dopamine boost.

Now I just have to adjust the values to my liking and find out how to add collisions. Will a 2D collider component work or do I have to do this entirely through scripting?


I would think either a PolygonCollider2D or an EdgeCollider2D would do the trick… underneath it I believe MelvMay told me that they’re all the same Box2D line collision object… but you will probably need to feed the segments of your polygon in manually, not sure if it would pick it up automagically. Try just adding it after you build the polygon; it might just do it.

This seems to be the defining marker for people who really enjoy coding. I know this is the case for me.

Did you use perlin noise for this example?

No, I just hand-placed those sprites.

If I were to use sprites like those to produce a level in code, I would probably premake ground chunks that contained two offset points that I could use to roughly match the ends up as I traversed across gaps of space where I wanted ground.

My current work is playing with 2D geometry through the Clipper2 and LibTess engines to make navigable cave interiors: I’m using Clipper2 to produce blobs of geometry by unioning odd shapes together, then putting them all inside a separate larger contour and feeding it to LibTess to produce geometry for the solid portion outside was formerly the geometry, now turned inside out.

It’s turning out okay so far, I just need to work on it some more… I tried to take a cool picture of a cavern intersection but rammed my spaceship into the wall right as I hit the screencap button.

“If you take pictures while you’re flying, eventually you’ll get a really good photo of your crash site.”

These caverns are made of squares, pentagons, hexagons rotated and stamped together and unioned with Clipper2, then as noted above, flipped inside out to produce geometry around it, with a LineRenderer “crust” around the interior.

PS: if you want to play with Clipper2 and LibTess, they’re awesome but the C# language boys got carried away and used C#10 and other crazy dynamic typed interface shenanigans that Unity does not like (at least for AOT targets like iOS / Android) so I ripped all that silliness out and made my own forked branches of the public repositories that can simply be dropped into Unity:

Clipper2 and LibTess for Unity3D:

I made Unity3D-friendly versions of the Clipper2 and LibTess projects:

Clipper2: GitHub - kurtdekker/Clipper2 at feature/Unity3D

LibTess: GitHub - kurtdekker/LibTessDotNet at feature/Unity3D

Both repos have a feature/Unity3D branch. Read the commits for more.

BTW, ChatGPT can give you pretty good examples of playing with simple stuff in Clipper2 and LibTess if you want to get started on it.