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. Dismiss Notice

Planets generation

Discussion in 'Scripting' started by diegzumillo, Jun 23, 2014.

  1. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Hi all

    Here's something that always interested me and now I'd like to hear someone else's thoughts on the subject: procedural generation of planets.

    My holy grail (and possibly everyone else's in this endeavour) is a planet generator that creates interesting variations, to make an exploration game actually rewarding. Evidently perlin noise terrain deformation gets old pretty quickly, even with different atmospheric shaders and different terrain textures. Using voxels would allow for more terrain variation right out of the box but it also comes with its own set of great problems, such as how to render voxels. Voxel engines that use proper voxel rendering techniques (such as raytracing) are a thing for graphics programmers to play around at this moment, still way out of reach of commoners such as myself. Rendering cubes can be problematic in long distances.

    Let's say one is able to solve these problems and create a voxel planet that looks nice from any distance. Creating interesting terrain using voxels is a little easier than deforming a terrain, but just how much I'm not able to tell without testing it, and how to improve this aspect is beyond me.

    Let's say one is able to make interesting terrain. Creating liquids and gases would probably be interesting as well, otherwise every planet will feel like a large asteroid. This is really difficult. Atmospheric shaders will always produce pretty much the same effect but with different colors and intensity. There is no naturally occurring variation, if you want any you need to put it there by hand, like clouds and things like that.

    Anyway, I've been thinking about what I could do in 2d. Maybe reducing a dimension simplifies these problems a bit. This 2d planet would of course be a slice of a planet. Drawing additional layers (background) to give the player some sense of scale would probably be nice but trickier.

    If I could make a system that produces interesting variations, it could be the ugliest thing in the world! it would be fantastic.
     
  2. Troas

    Troas

    Joined:
    Jan 26, 2013
    Posts:
    157
    Maybe instead of trying to randomly generate a planet from one giant random generator, you have a series of generators with limitations to what their randomized variables can be.

    For instance, you want variety of planets so first settle on the different types of planets you want.

    Lets just do basic ones like Gas Giant, Rocky/Earth Like, Super-Earths, Dwarf Planets.

    So make a method that randomly picks any of these 4 types.

    Once that is done, have parameters that the planets have for their color, size, gravity, location vs star, amount of water, amount of gas, types of gases, types of minerals, ect.

    Maybe have the color based on what type of gas, liquid, and solids they have, and give even these gases liquids and solids parameters that the program can randomly choose based on limitations you set.

    Even further have random variables unique to only certain types of planets eg:
    Only Gas Giants can have large amounts of moons or asteroids around them.
    Super-Earths have more extreme weather due to gravity than regular sized Earth-like planets.
    Dwarf Planets can't have atmosphere but can have their own internal source of heat and specialized life adapted to that.

    Even more create special conditions based on the stars they are around.


    Though since this is all theoretical I wager what I just said is a monolithic amount of code. Though it's fun to talk about and I hope you find a way to pull it off.
     
  3. FreeSide Games

    FreeSide Games

    Joined:
    Jun 24, 2014
    Posts:
    19
    Hello there!

    Your idea is wonderful, it stands as a time consumer though.
    Having a consistent flow and a completely different planet would be exactly like programming 2 and a half mine crafts from scratch. if you plan to achieve something like our galaxy, different here, different there. Is a huge leap of progress, if you pull a game off like this you will make history. Let me explain exactly this...

    You want completely different like our galaxy, beautiful landscape.
    Different skies, weather on the planets is a huge part! Rich history, quests, each planet with there own speech.
    Different houses, problem the player needs to solve! Caves, creatures, building aspects.
    ETC, i would not recommend going for a random generations if you are going for skyrim 2x game of the year edition.
    GO BIG OR GO HOME!

    I wish you luck, to you or who ever decides to pull this 10,000 between 100,000 lines of code into place.

    ~FreeSide Games
     
  4. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Thanks for the encouragement :D although right now I'm just thinking and reading.
     
  5. Troas

    Troas

    Joined:
    Jan 26, 2013
    Posts:
    157
    There was a guy on here, I believe it's somewhere in the Showcase forum section, that has already created a pixel art game using this idea of procedurally generated galaxies. Try and find it, I'll see if I can find it myself and post it here.
     
  6. Deequation

    Deequation

    Joined:
    Jan 2, 2014
    Posts:
    16


    The most common way to generate a terrain is to create the terrain or texture with a noise function. But another easier to handle stepwise - but more demanding to master way of doing it is to create algorithms to generate it for you. Here are some examples of different noises, a generation algorithm and a result from the algorithm.



    [01] Using a noise to generate height maps or textures:


    This has the benefit of being an easy to approach and easy to setup way, and you can adjust the parameters of the noise generation to get different end results. You should note that there are many different types of noises, with very different outcomes. The most known one is probably perlin, but there are other types also and they all serve very different purposes. In the image an example of Perlin-, Value-, Worley- and Fractal- noises.





    [02] Using an algorithm to generate a terrain:


    By using a combination of algorithms and some random probability checks, you can create a list of algorithmic moves that by adjusting the parameters can create a lot of really nice looking terrains, where you ideally can tweak very specific things but also change the whole layout. Here is an example of using algorithms to generate a low resolution 2D tile map base of an island with a beach. The image shows four of the algorithms used to generate it, to illustrate how algorithms stepwise creates something. The code for this is available if anyone wants it by contacting me and is used in a higher resolution for the following.





    [03] UV wrapping the previous texture:


    Here is an example using a default sphere as planet model, and by wrapped a normal texture around it to generate a planet looking model. The drawback to this is that you won't get planets that has visual mountains or valleys when viewed from this perspective, as they follow the sphere mesh. You could in theory also generate the mesh randomly to contain these, based on the texture or the other way around. Note that this has an added randomized cloud overlay sphere, following the same generation steps as the island - and the beaches really came out too small to see.





     
    Last edited: Jul 22, 2015
    Thoaril and sam_fisher3000 like this.