Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

tiny planet generator

Discussion in 'Works In Progress - Archive' started by trialnterrorgames, Oct 19, 2015.

  1. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    A couple of days ago I got inspired by this image of a "tiny planet":



    So I set out to try and create a random planet generator that could create this kind of cartoony planets.

    After working on it for some days, I'm starting to see some results. I know that the textures are pretty much crap, and the colors aren't exactly an artist-rendering, but I feel I'm going in the right direction with this.






    I've been using a LibNoise Unity port for just about anything, and I think I've gotten to a point where I can start generating all kinds of planets.

    Right now you can modify the planet parameters "live" in a low res version, after which a high res version is rendered. (almost) Everything is threaded, so doesn't freeze up Unity or anything.

    The next thing I'd like to add is a brush modelling tool, so you can sculpt out some custom terrain on the planet. I don't know if I will implement it, but it might be an interesting project.

    Suggestions and remarks are always welcome!
     
    theANMATOR2b likes this.
  2. Rombie

    Rombie

    Joined:
    Feb 18, 2015
    Posts:
    282
    Wow this is neat. I think you are definitely going in the right direction from your photo of inspiration.

    The sculpting idea is great and I think you should add it in.

    You planning to sell this on the asset store by any chance?

    Keep up the great work!
     
  3. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Hi Rombie!

    I'm not even sure if I'm allowed to sell it (I haven't read the LibNoise license yet, so I don't know if I can include it into an asset).

    If I get that far, I'll be sure to post it here!
     
    Rick- likes this.
  4. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Update on the brush modelling, by either directly painting on the heightmap or on the planet itself:



    Some bugs are still there, the seam painting isn't perfect yet and painting at the poles is currently a bit weird.
     
  5. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    And a final update for tonight on the generator (changing the parameters shouldn't be this cluncky, don't know why it's this slow in the video):

     
  6. PitHeimes

    PitHeimes

    Joined:
    Oct 18, 2015
    Posts:
    322
    Neat work. Looks really good. Like the sculpting feature!
     
  7. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Been making some code improvements here and there, so I decided to create some presets.

    After 5 minutes of fiddeling I got an earth-like planet and a moon-like thingy:


    I'm going to merge the sculpting part with the generator part, so you can generate a planet and then sculpt it to your liking.
    I'm also going to look into a decent ocean shader.
     
    Mister-D and kittik like this.
  8. ironbellystudios

    ironbellystudios

    Joined:
    Jul 21, 2015
    Posts:
    410
    That's pretty clever. I could see a lot of fun applications for such a tool given all the space games we're seeing lately.
     
  9. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Thanks! There is still some deformation at the poles, because it's basically heightmap painting, but it's managable.

    I'm glad you like it :) Collision meshes are fully working now. I'm looking into giving the option to generate biomes on the planet surface that can be textured and adjusted separately.

    I've also generated some octahedrons to use as a basemesh. Previously I was generating them in the script itself, but now it seems like it makes things just more complicated. Now it just uses the mesh given to the meshrenderer, so a developer can choose any type of mesh to start from.
    Although I'm starting to think I should be using a classic sphere. Octahedron sphere have this diamond shaped artifact at the poles, which result in a very disturbing "cross shaped hole" when using a heightmap.
     
  10. PrettyFlyGames

    PrettyFlyGames

    Joined:
    Aug 30, 2012
    Posts:
    74
    Wow that seems very useful and simple to use. Looking at I'm coming up with lots of good ideas where you could use this in space games :)

    Keep up the good work!
     
  11. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Just a bit of showing off in this post :)

    So with a single preset I'm able to generate an endless stream of variations of that preset. Below you see the preset I used above, each with a different seed. It never outputs the same planet twice, while it keeps the same look and feel for each planet.
    (Oops, forgot to animate one)

     
  12. Deleted User

    Deleted User

    Guest

    Interesting! It looks like the biome map from Kerbal Space Program.
     
  13. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    And one more preset before I go to sleep: a lava planet (I'm not an artist, so I know this can be made a whole lot better). It's possible I might create different setup inspectors for different planet types, so the settings in the inspector make more sence for these kinds of things...

     
  14. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Thanks! I've found out I can use Libnoise to create stuff to distribute, so I'm seriously considering putting this on the Asset store.

    I hope by adding textures and asking a artist friend of mine to try this tool out that things can start to look even better ;-)
     
  15. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Been a while since I've updated this thread...

    I've been experimenting with some atmospheric glow. I forgot how hard writing shaders can be! But after a lot of swearing and figuring out some odd things I still don't fully understand, I'm almost finished with the atmosphere.

    After this it's time to add some textures! I'm still not sure on how to implement this in the most user-friendly way...
    - Should it be height-based? Downside is it will only allow 1 texture for each height range, so a desert and a medow on the same height wouldn't be possible... On the other hand, it might be the most intuitive. It would be possible to link it to the markers used in the gradient for the height-coloring, + it would also make it easy to create some debugging coloring.
    - Should it be based on a separate generated biome map? I'm reluctand to add another level of complexity on top of the generated planet.
    - Should it be a combination? The biome map being applied to the "intermediate" heights, while mountains and oceans have a default texture slot.
    - Or should I implement all of it, and leave the choice to the user?

    When I finish up the atmosphere shader, I'll put up some new screenshots!
     
  16. jpv1234

    jpv1234

    Joined:
    Dec 5, 2014
    Posts:
    89
    I'm really interested in using this! Please consider uploading it to the asset store!

    Really good job!
     
  17. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    So another badly needed update on this project! This is actually 2 updates in 1 :)

    First update:
    As I said in my last post, I've started working on an atmosphere shader. As it turns out: shaders aren 't really my thing :D
    However, here is a first attempt at a cartoony atmosphere shader: (sorry, the ocean/water has been turned off in the screenshots)



    Still a lot of finetuning needs to be done, but I'm slowly getting there!


    Update 2:
    I noticed on the forums that there are more and more people working on something similar, so I started looking into what it is that I myself am actually looking to get from this project.

    So the goal of this project has shifted/expanded to do the following:
    - create a random tiny planet with collision mesh
    - add a or several pathfinding solutions for the terrain
    - generate biomes (forests etc..) and populate them with props
    - generate small towns to place on the planet

    To do this I've actually reworked a lot, and I've created some kind of grid system that is able to generate a mesh from the grid, add pathfinding (A* and FlowField) to that grid, and a cellular automata algorithm for controlled biome generation.

    Below a first attempt at forest generation:



    Update 2bis:
    I think I've worked out how to remove the distortion at the poles. Still some experimentation to do, but I think I'm almost there :)
     
  18. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Now that I'm using a grid to define my 'terrain' I can actually use all kinds of grids to work with this. Below you see a hex grid, with some different forrest types generated, while a flowfield has been generated for the entire map towards the sphere in the bottom right corner and an A* agent has found a path to the sphere on top.

     
  19. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Screenshots below might not be shiny-fancy-graphics-pictures, but the next step in my world generation was generating random villages and towns, and that is what you see below: random streetmaps with spots for houses along the streets :D


     
    Rombie likes this.
  20. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Next step: creating a more complex planet with all previously implemented systems. So a planet with randomized forests and 1 or 2 towns, on which the 2 types of AI can walk around and find their way based on the type of surface they are on.

    After that, I'm going to try to implement all of my old code (so the initial project code) into the new project, so that I can actually create the nice(r) looking planets from the first screenshots in this topic with all the forest, AI and town systems. March is going to be an exciting month!!!
     
  21. Rombie

    Rombie

    Joined:
    Feb 18, 2015
    Posts:
    282
    Looking great; keep it up. I'm very interested to seeing what this develops into. Great work so far.
     
  22. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    There are several different types of this idea being worked on, yes, but this one seems the most interesting and promising to me, and quite possibly the most suited for my visual style as well.

    Keep up the great work!
     
  23. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Thanks! I'm curious as well to see what this will become :D

    Always nice to hear :D Can you tell what features are more or less interesting?

    Btw, if you have any suggestions for any other features that I might add into this, you're always welcome to PM me or put something here on the forum. I'm still figuring out how far I'm going to go with this project, and what types of features are interesting for other people.
     
  24. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    I love the idea of defining parameters to planet types, and then being able to generate variants of that type. I'm also interested in being able to use the generated planet's settings to construct a matching terrain. I don't need (nor want) the full scalability of flying around a planet and landing anywhere on the surface. Rather, I need to have planets the player would see from far orbit, and then a limited piece of area they'd see upon landing.

    So from their ship, they'd see a pink planet with purple atmosphere and green oceans. A few clicks later, they'd have their character on the surface, with a semi-randomized block of 1000m x 1000m terrain of pink ground, purple sky, and potentially green ocean. Does that make sense?
     
  25. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    I think I get the gist. Would the surface need to be an exact (partial) copy of the planet rendered, or it just needs to be created with the same parameters to create a similar looking surface?
     
  26. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Nah, just the gist for my needs. No round body gravity or anything like that. Maybe just like a configurable type (mountainous, valley, swamp, grassy, etc) or something.

    Keep in mind, my needs are probably different from your target customer. Many entrepreneurial young developers would drool over the possibility of fully-realized planets with seamless transitioning from surface to atmosphere, but I'm just trying to keep things manageable.

    In any case, I'm definitely following your progress closely.
     
  27. trialnterrorgames

    trialnterrorgames

    Joined:
    Feb 20, 2014
    Posts:
    58
    Alright, great! Well, no matter if it would be just for one person or not, this would be easy enough to implement with the code I already have, so I don't see any issues with actually implementing this feature.


    Another thing I've come across a lot recently is base-building assets and games. I've seen it pop up here on the forums and on some tutorial-youtube channels. I think I actually have most of the code needed for this, so I think I can also create a module for base-building.
    The only thing I'm wondering about is that I can't seem to find any games that revolve around these base-building mechanics. If anyone can point me in the right direction of some games that work like this, I'd be grateful!
    ( to give some example of what I mean:
    Here on the forums:
    http://forum.unity3d.com/threads/wi...pathfinder-an-asset-for-game-creators.389227/
    On youtube:
    )