Search Unity

Procedural Planet Generator

Discussion in 'Works In Progress - Archive' started by SkavenPlanet, Aug 24, 2014.

  1. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33





    Hey everyone,

    I've been working on a realtime procedural planet generator that's part of a larger project which I'll hopefully be revealing soon. The planet is generated by 3D cell and perlin noise algorithms on the GPU to generate object-space normal maps and colors while also displacing vertices on the CPU (for mesh colliders). The planet uses a quadtree LOD system for seamless transitioning from space to surface. As far as performance goes, the view shown in the screenshot above was rendered at ~80 fps and there is still plenty of optimization to be done. Currently planetary rings (check the screenshot above - I know the shadows aren't right yet but they still look cool imho), an ocean renderer (check the most recent quick update), procedural textures, flora, asteroids, and rocks are other major features in the works and hopefully I'll be able to show more of that stuff off soon. The screenshots above are relatively new and depict a Gaian world with rings, an ocean, and much more surface detail than in the [old] screenshots below.








     
    Last edited: Apr 4, 2015
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Looks pretty good... How about texturing? Did you use a regular sphere with poles or did you use an Icosphere?
     
  3. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    I used a quadrilateralized cube sphere as it seemed to be the easiest choice from the start, also works very well with quadtrees.
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Ahh yes. I was just making sure you didn't use a polar sphere as it's bad for UV texturing (pinching at the poles). :) I actually have code to generate and subdivide Icospheres but it was something I wrote for XNA which is why I was asking. ;) I can certainly see how subdivided cube would be better for quad tree partitioning. Out of curiosity, why a QuadTree since it's really designed more for 2D data storage? I would have that that Octree would be a better choice, although higher memory requirements and some wasted storage space (partitioning for the inside of your sphere).
     
  5. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Well since I'm only using 2D heightmaps to generate the terrain so quadtrees are sufficient and there would be no benefit to using octree especially because, as you said, more unecessary memory usage. If (and once) I have subsurface spaces and caves working then octrees would be worth using.
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    That makes sense. You're using the Quad Tree in relation to your heightmap coordinates.
     
  7. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Quick Update: Atmosphere Test

    Within the past week or so I've optimized the code and added a crater noise module, then decided to increase the vertex density of the patches which set performance back again (but it still runs better than before). Currently I get 60-65 fps on a three year old iMac when just flying around the planet at virtually any altitude. To optimize the code I multithreaded the mesh deformation and edge stitching functions then rewrote a bit of the heightmap generation code to create a high-res texture for normal mapping and coloration and a lower-res texture for mesh deformation. Having a separate heightmap for the vertices also allowed for 32 bit precision (encoding a float into an 8 bit per channel texture) that way the camera can get closer to the ground before things get wacky.

    I also began working on atmosphere scattering and ran a test with Sean O'Neil's method which didn't turn out as well as I hoped. It looks decent from the surface but a seamless transition from ground to space isn't possible as separate shaders are required. I'm already in the process in implementing Eric Bruneton's precomputed atmospheric scattering which looks far more advanced and realistic. Here are some screenshots for now though:


    Screenshot37.png Screenshot38.png
    Screenshot40.png Screenshot42.png Screenshot43.png
     
    DizzyTornado and Sir-Spunky like this.
  8. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    look pretty good! what is the poly range when you use unity quick profiler?
    are you going to release this?
     
  9. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    I'm not exactly sure what/where the "quick profiler" is but there are 100,000+ vertices and 200,000+ triangles onscreen viewing from ~2 meters off the ground, once I add horizon culling that will be reduced by a lot as many unnecessary patches of terrain are rendered which aren't culled by frustum culling. To answer your second question, I am still deciding whether or not I'll release it on the Asset Store.
     
  10. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    Just want to chime in and also express my interest when this asset is released in the store. Looking pretty good.
     
  11. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Quick Update: Atmosphere Test 2

    Check the original post for images. The new atmospheric scattering is not done yet, needs some optimization, and still has bugs but so far it looks considerably better than the first atmosphere test. It's rendered as a single post processing effect and currently runs at ~20 fps on my 5 year old hardware (256 MB Video), I need to test it on a more recent computer but I'm speculating that the framerate will be much higher on a computer with at least 1 GB of VRAM.

    EDIT: I got the framerate back up to 60 fps by, paradoxically, increasing the quality settings and disabling vsync.
     
    Last edited: Sep 29, 2014
  12. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Looks great. Well done :)
     
  13. mathias234

    mathias234

    Joined:
    Sep 9, 2012
    Posts:
    239
    Looks Good :)
     
  14. MrIntel

    MrIntel

    Joined:
    Jul 4, 2014
    Posts:
    43
    Is this still being worked on? it is exactly what i need.
     
  15. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Yes, but if I release an Asset Store version it won't be for a little while longer since I'm working on procedural flora, ocean rendering, and other aspects of my game at the moment in addition to handling precision issues so that a game that uses the procedural planet system will run smoothly.
     
    Last edited: Jan 11, 2015
  16. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    If you put this on the asset store I would buy it for $100+. This looks like a really promising project!
     
    Last edited: Jan 1, 2016
  17. Paul Bernhardt

    Paul Bernhardt

    Joined:
    Oct 9, 2013
    Posts:
    5
    I would also be interested in this potentially if it went on the store. I don't need flora for my current project. There are several dead procedural planets plugins floating around, it would be nice to have a working one.
     
  18. MrIntel

    MrIntel

    Joined:
    Jul 4, 2014
    Posts:
    43
    May i ask how you are generating your noise as i am doing the same system with my game i just cant seem to get the noise generation right?
     
  19. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Just sent you a private message. Hope to hear from you soon.
     
  20. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Really have to hand it to you: some of those planet renders and horizon renders are fantastic. I sent you a private message about that. Looking forward to hearing from you!
     
  21. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Just to give some info about my work history:
    Epic Games (Unreal Tournament 2004 Onslaught vehicle/weapon artist)
    Red Storm (Ghost Recon2 - general 3d/2d artist
    Psyonix (Lead Artist when they began)
    RealmWare (3d game engine company - various 3d/2d assets/tests)
    Ignition Entertainment (Gainesville, FL - "Reich" (it ran out of time)

    20 years in Photoshop
    19 years in 3D Studio Max
    12 years as professional game artist

    For my current Unity project, I have a full design doc with tons of concept art, and can show you over a dozen finished assets for one player class. Your planet/terrain renderer would be a huge part of that game, but would need some further additions (player deformable terrain on a very large scale) and a lot more. If you're interested, let me know.
     
  22. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    380
    Looks pretty good ? :D Looks far more better than KSP planets, and those guys are pros and highly skilled programmers :D
    So I think it looks amazing or better :)
     
  23. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Has anyone heard from the individual that made this thing? I sent him a private message, and these above, but zero answers to any of us.
     
  24. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Well I'm not on the forums very often, however I responded to your PM on Tuesday and I have responded to most of the people who have asked specific questions here or in PM's so I don't unnecessarily bump this thread - who did I not (eventually) respond to?
     
  25. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Hey there! I don't see a response to my post from you on Tuesday, unless I've somehow errantly deleted it? Not sure what happened. Again, kudos on the work: It's really strong. Have you entertained the idea of creating a larger game with this engine, or are you interested in just making a random planet generator standalone?
     
  26. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Yes, it was developed as a part of a larger game from the start; I guess I sort of lied when I said what exactly that game is will be revealed sooner than later though. At the moment I'll say that the game will rely heavily on procedural generation, evolutionary algorithms, and real-scale, dynamic environments and conceptually was influenced by SpaceEngine, Spore, and KSP.
     
  27. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Quick Update: Ocean Rendering

    Most of the time between now and the last update I've been working on a procedural flora generator which I'm not ready to show yet and a BTS code of sorts that generates and simulates a working solar system among other features and improvements and sort of procrastinated on the ocean rendering. Therefore, it's currently less than a week into development. To start with I used Scrawk's CPU FFT ocean project and built upon it to get my current ocean shader. In the screenshots below I'm using a simple test scene with the built-in terrain and a few primitives to demonstrate that the underwater scattering effect is updated in real-time and doesn't rely on precomputed height maps. Also the SSR may appear incorrect because I had to offset the reflection camera height otherwise I would get some distracting artifacts where the wave vertices were higher than the camera height thus ultimately reflecting/refracting nothing. The shader also features sub-surface scattering but it too needs to be tweaked. Caustics, underwater viewing, and a few other features still need to be added but so far I think that it looks decent.





     
    Last edited: Mar 11, 2015
  28. Alphalpha

    Alphalpha

    Joined:
    Oct 9, 2013
    Posts:
    74
    This looks nice. It'd be great to have something like this that's actually supported.
     
  29. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Do you have a release date yet? I wouldn't mind using as is, lol.
     
  30. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    No release date (as an asset) at the moment, a lot of features still have to be finished, most notably the star system generator w/ n-body physics, gas giants, procedural (and evolving) flora, ocean rendering and buoyancy, more procedural noise modules, rings, volumetric planet (and ring) shadows (on atmospheres), shadow mapping, and procedural textures, most of which are pretty complex features and I'm just one person who works on this in their spare time so it's going to be a while.

    That being said if I were to release this on the asset store would most people actually be able to make a game with it (considering it's pretty much a rather intricate engine existing inside of Unity)? A lot of the conveniently built-in features don't work well or at all due to the many precision issues so surface shaders, built-in shadow mapping, non-logarithmic depth buffers, etc. are not really an option, also there's no DX11 support (for several reasons). Because everything favors scientific accuracy over customizability, for example the atmospheric scattering, there's not a lot of room for artistic control unless you know the in's and out's of the algorithm used which is fine for my purposes but may limit the results for someone else's project. Finally, I'd rather not release this as an asset just for people only to mess around with it since the game I'm working on will allow them to do that anyway ;).
     
    DizzyTornado likes this.
  31. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    That makes sense, I was interested in it because in my game I could not decide whether to make planets that have seamless transition, or planets whitch load a flat terrain when you pass the atmosphere. I wanted to do the first but as I needed to focus on other aspects of the game, i wouldnt have had enough time to work on it, so I decided to use the other, but now that I have found this I would still be able to make seamless transition planets.
     
    Last edited: Jan 1, 2016
  32. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    Well, hopefully it will allow players to actually play on planet surfaces, and a way can be found for the other features of Unity to be incorporated. Without them, it's like spaceEngine: pretty...and pointless.
     
  33. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Well players will definitely be able to play on the surface since I'm already generating collision meshes for patches of subdivision depth > 12, rigidbodies still work (with some modification), and all of the basics because I use floating origin. Problems start to arise when you want to use built-in navmesh generation (although I am going to implement my own), some of the built-in post effects like SSAO, etc. so these things have to be rewritten or heavily modified.
     
    DizzyTornado likes this.
  34. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    20
    feels really nice see that comin up ..--
     
  35. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    That's promising! I contacted you before regarding a procedural planet generator with Gpu texture creation. It was some time back, but I'm glad to see you've continued on it.
     
    DizzyTornado likes this.
  36. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    And if you're NOT releasing this as a standalone plugin, what's the point? People aren't interested in being locked in your game. They want these features for their own games, as evidenced by the massive outcry for such a plugin on the boards. If you heed that call you can likely make a volume more from such a plugin than from just a game using it.
     
    DizzyTornado likes this.
  37. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Are you still working on this? Will you post more updates? I'm definitely interested in using this for my game!
     
  38. davidsirmons

    davidsirmons

    Joined:
    Mar 16, 2014
    Posts:
    190
    I assume GPU textures/normals for terrain eventually?...
     
  39. IO-Fox

    IO-Fox

    Joined:
    Jul 14, 2014
    Posts:
    86
    Hey :) Any new updates regarding this project?
     
  40. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Any release date? I would be willing to test it as is just for fun/QA testing.
     
  41. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    The project is very much alive and I'll post more updates soon.
     
    DizzyTornado likes this.
  42. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    20
    jo hye -..- enjoyin summer now .. still on doin- bringin that project up? -- anything to try out ..-? beta ??also willing to test it as it is just for fun/QA testing.
     
  43. ViperG

    ViperG

    Joined:
    Jun 24, 2015
    Posts:
    6
    I would definitely be interested in this. Would i be able to spawn in planets (seed a small galaxy or solar system) based on a new game? (random system/galaxy every game etc etc)
     
  44. SkavenPlanet

    SkavenPlanet

    Joined:
    Jan 20, 2014
    Posts:
    33
    Solar system - yes. Galaxy - not at the moment.
     
  45. Strategos

    Strategos

    Joined:
    Aug 24, 2012
    Posts:
    255
    Very impressive, colour me interested.
     
  46. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Any updates?
     
  47. LazyMan

    LazyMan

    Joined:
    Dec 7, 2013
    Posts:
    26
    Hello! Any updates?
     
  48. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    Is this still a thing? I can't wait to be able to use it!
     
  49. IO-Fox

    IO-Fox

    Joined:
    Jul 14, 2014
    Posts:
    86
    I doubt it. Only screenshots. No updates from OP. No demo(s). I believe we refer to this as vaporware.
     
  50. DizzyTornado

    DizzyTornado

    Joined:
    Nov 17, 2013
    Posts:
    134
    I hope not... This was really promising...