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

Procedural Spaceship Generator

Discussion in 'Works In Progress - Archive' started by FPires, Dec 9, 2016.

  1. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Hey there.
    I've been working for the past few weeks on a procedural model generator in Unity. The idea is to combine set pieces using a generation tree and linking them together.

    After working on the base set of the script for a while I'm working on implementing an algorithm to generate simple starfighters.

    Here's my progress so far:

    spaceships1.jpg
     
  2. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    spaceships4.jpg

    spaceships6.jpg

    Cranking up the details.
     
    tobiass, Firlefanz73, Flurgle and 3 others like this.
  3. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    This is an asset I did not expect to see. It definitely looks interesting so I'll give it a watch.
     
  4. 00Fant

    00Fant

    Joined:
    Mar 10, 2015
    Posts:
    131
    uhhhh that looks Nice. i keep it in my eyes.
     
  5. 00Fant

    00Fant

    Joined:
    Mar 10, 2015
    Posts:
    131
    one question. they are walkable :D? with rooms / corridors? (simple rooms not complex )
     
  6. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    @Billy4184 and @neoshaman might be interested in seeing this.

    I did try something similar once, but it was a lot of work to set up the "spawnpoints" for different parts on other parts. I abandoned it because I thought that a more random process where then afterwards a human picks the few cool looking things from might be more practical for me.
    I'm very interested to see where you are going with this!
     
    Billy4184 and neoshaman like this.
  7. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    I was already there lol, it's a slot system like no man sky
     
    Martin_H likes this.
  8. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    That's a very interesting project @FPires. Would be interested to know how much and what kind of information is preset before the model is generated?
     
    Martin_H likes this.
  9. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Here's a few more demos:



    spaceshipsA.jpg

    spaceshipsB.jpg

    spaceshipsC.jpg
     
    RogDolos and Martin_H like this.
  10. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    As it is right now, not much. It is very verbose, but the parameters are simple. For example, once the script creates the cockpit, it then gets a connector using custom parameters to get a random connector with a "body" tag, and from the back of the cockpit (or more rarely the bottom).

    Afterwards it adds the body passing another custom set of parameters, etc. The tool itself is an API to connect these or any other custom blocks.

    It was, yeah. I made around 250 models and they have 5 connectors on average. The connectors can be points or meshes so that a greeble can spawn anywhere in the connector surface.

    Not really, no. I intend to do this eventually but since this is a personal project I'm doing on my spare time, "eventually" might be anywhere from "one year from now" to "never". It's not a priority because it can be quite challenging to do it right.
     
    Last edited: Dec 10, 2016
    Billy4184, Martin_H and 00Fant like this.
  11. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Some coloring. The mesh vertices have different RGB values that are used as a weight for the shader. The shader can then selectively color the mesh based on these weights.

    spaceships10.jpg

    spaceships8.jpg

    spaceships9.jpg
     
  12. This is amazing! :O
    Eta?
     
  13. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    These look pretty nice. But I notice most people who make spaceships or alien ships seem to always make very 'realistic' looking mechanical objects which are a bit lifeless. I want my alien ships to be more organic and alive and less like some kind of machine. Just a thought.
     
    Billy4184 likes this.
  14. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    I definitely agree with this - I've always seen my spaceships as character-driven, like saddled animals and I've always been impressed with 'organic' hardsurface shapes myself. It's one reason why I've tried not to go down the route of too much greebles myself.

    I'd be interested to know OP if you have any plans/ideas for how to achieve a more visceral impression? I think it would be the next step for making your generated ships more appealing. I think it might be interesting to attempt to fit a set of rules for placing parts that corresponds to a human/animal body? Just a thought anyway.
     
  15. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    My original goal was to make ships that look like the traditional human-made machines in series like BSG and Star Wars. I'll have to clean up this tool a lot before I release it, but If I ever do release it I'll keep your needs in mind.

    Right now the tool is divided in four parts:
    * The API
    * The Addons
    * The Mesh blocks
    * The Algorithm scripts

    The main aspect of the tool is the API to link the blocks together. You can do whatever you want with them via script, so if I want to make a script that places ship parts corresponding to animal parts, that should be very trivial to do.

    The blocks themselves are customizable and so are the algorithms, but I do have some ideas that could improve on the appearance of organic ships. Right now I'm working on a system to generate viable materials for the models. Once I'm done with it I'll research my ideas for organic ships.
     
    RogDolos likes this.
  16. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Really happy with this:

    UVW.png

    The generated model now splits UVs with no overlaps. The usage of space isn't 100% optimal, but the generated UVs are scaled proportionally to the block size relative to the final model, so everything is uniform - a single texture applied to the whole model won't make the small greeble look super detailed compared to the cockpit, etc.
     
  17. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    In terms of generating a ship, do you have a nice user interface with sliders etc where you can adjust certain aspects of what gets created, then have the system automatically generate the result? And could it generate lots of different variations quickly?
     
    00Fant likes this.
  18. 00Fant

    00Fant

    Joined:
    Mar 10, 2015
    Posts:
    131
    that was perfect :D
    something like that need i for my project.
     
  19. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    Sounds and looks pretty cool!
     
  20. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Not right now, no. There's no interface.

    I have a roadmap to do right now which I've been progressing at a fairly decent pace. I'm gonna post it as I do it so as not to create expectations. If I can complete the roadmap I'll release the tool, otherwise I'll keep it to my own projects. I say this because part of the roadmap is refactoring a lot of the code so that it is accessible and readable to possible buyers, and fixing a lot of bugs which make it simply unrealistic to release it right now at any price tag. There's 2000 lines of code of linear algebra and it's not uncommon to find an oversight here or there.

    I have a very good idea of how I want a possible interface for this tool to look like. I wouldn't release it without a very good and intuitive GUI to use.

    In other news, I got some improvements on my UVW Mapper and fixed some bugs.

    uvws4.png

    When dealing with procedural textures the important aspect is to keep things uniform and non-overlapping. A nice improvement would be for it to recognize the empty spaces in the UVW of individual objects and take that in consideration to use the final space better, but I'm very, very happy with where it is right now.

    As it is, a ship with 40~50 parts is taking 0.09 - 0.1 second to generate which more than fits my goal of being able to generate them during the loading screen for my game. Once texture generation kicks in this number will probably go up a bit, but I believe it will still very manageable.
     
    Last edited: Dec 15, 2016
    RogDolos and RavenOfCode like this.
  21. I cant say this enough, man| This is amazing!
     
  22. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    This looks really cool, looking forward to see this with textures! :)
     
  23. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
  24. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    I didn't know that existed. The only procedural model tools I know of are building/city generators.

    I can see the similarities, though I imagine they are a bit unavoidable when it comes down to placing blocks together at random. Pretty cool website, his tool generates some very cool looking stuff.
     
  25. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    I've been playing with texture operations and planet generation lately. I started with real-time noise generation for procedural texturing, implemented a texture operations suit, and then realized I could start playing with quadrilaterized spheres to create planets:

    planetb4.jpg

    planetc0.jpg
     
    _M_S_D_, RavenOfCode and Bejasc like this.
  26. Is this project still live? I need it...
     
  27. Zymes

    Zymes

    Joined:
    Feb 8, 2017
    Posts:
    106
    Really cool. I can see a use for this. Hope you can release it.
     
  28. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Hey. I'm still working on it. My time has been mostly focused on my game right now that I finished the tools for my purposes. Once I'm done with my game's code I'll revisit the asset to launch it.

    Before launching it I intend to clean up some bugs with symmetries and add some additional features such as themes (being able to replace the models from an existing generated object with equivalent models from other themes, such as a high-poly theme that simply improves the look). I'll make a roadmap when I'm closer to it.
     
  29. If you *coff* *coff* need beta testers *coff* call me ;)
     
  30. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Looks stunning!
     
  31. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    I probably will, though I'm a bit far off.

    Thanks!
     
  32. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    A bit of an eye-candy - more on my quadrilaterized sphere script. Each planet takes about 11-20 seconds.

    planetnew1.jpg
     
    alexanderameye and RavenOfCode like this.
  33. Don't worry, i can wait :p Although i can help you with some minor optimization if necessary. (In case you haven't noticed, i absolutely love this thing)
     
  34. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Any updates?
     
  35. I'm still crying myself to sleep every night because i don't have this tool
     
    alexanderameye likes this.
  36. 00Fant

    00Fant

    Joined:
    Mar 10, 2015
    Posts:
    131
    why cry?, write ur own. =)
     
  37. "Why be poor? Make money!"
     
    00Fant likes this.
  38. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    I don't have any updates yet. I'm super busy between work and writing my game, and time has been extremely scarce even for that. With that said I haven't abandoned the tool or the thread (I'm here, right?), I just don't have any ETA.

    Also I've been getting quite a few questions regarding procedural generation. I don't mind answering them, but if you have any question I'd appreciate if they were posted here so the answer could be shared with others.
     
    Martin_H and alexanderameye like this.
  39. Planning on open sourcing?
     
  40. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    No, but I don't see any reason not to answer some stuff publicly. For an engine this big there's a surprisingly low amount of resources on some areas of development and it'd help people in the future who are googling for solutions.
     
    Last edited: Apr 18, 2017
  41. knorton01

    knorton01

    Joined:
    Oct 17, 2017
    Posts:
    3
    It's been a few months, and I'm curious to know how the project stands. It's definitely beautiful, and google has it listed in the top five in the search result for "procedural spaceship generation".

    Anyways, I'm glad I stumbled across this page.
     
    alexanderameye likes this.
  42. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Hey. I haven't abandoned the project. I'm actually working full time on it, albeit in a different manner - I'm using the original algorithm to write a procedural shmup.

    Some videos depicting the progress over the past few months:





    If you have a SomethingAwful account, I've been posting my progress here. I intend to open up a site/blog in the future when I have some more content.

    Albeit it's not user-friendly and with no GUI (only scripting), the asset works for my purposes right now, and working on the asset is secondary to the game as it is. I want to work on my game before I release the model generator.

    However, I haven't abandoned the idea of working on an interface and release the tool. Just recently I started refactoring the code in order to add some new features. This gave me the opportunity to clean up some of the code and during the refactoring I coded thinking of user-friendliness. So I'm still developing it while keeping in mind a release in the future.

    A lot of features that I believe to be necessary for the asset are also things I'm developing and battle-testing the best way possible, with my own income as a game developer depending on it. A few things to name:

    The essentials:
    1) Algorithm speed. Trying to optimize to make this as fast as possible.
    2) Fixing any memory leakage whatsoever.
    3) Bug fixes. When dealing with something as delicate as this, there are so many. Just recently, for example, I fixed an oversight which is what happens when a model crosses the 65k vertices. Since the original ships were fairly low-poly, this took a while to happen.
    4) Flexibility. I rewrote a lot of the stuff in my script to make it as generic as possible, without needing to tie it to my own game.
    Possible Features:
    1) Possibility of multiple algorithms for different objects. I've had this in mind for a few months, so everything I write I write thinking that in the future this program might be sold as an asset to someone who wants to generate a house, a city, or a procedural sword.
    2) Simplified collision meshes
    3) Support to procedural textures. This is halfway done, and the algorithm allows you to include either existing textures or substances.
    4) Support to "skins". Basically, allowing multiple themes to apply over a generated object. This way simple low-poly blocks can be used and substituted by hi-def high poly models, for example.

    Anyway, there are other features in the works. Right now I changed the scripts to use a faux DNA system that allows me to mix different algorithms.

    I really want to see what happens when I mix an X-Wing with a TIE Fighter.
     
    Last edited: Oct 17, 2017
  43. knorton01

    knorton01

    Joined:
    Oct 17, 2017
    Posts:
    3
    The project looks good!

    Edit: The somethingaweful page (looking at it just now) is extremely detailed and helpful. Thank you for all the in-depth notes.
     
    Last edited: Oct 27, 2017
  44. knorton01

    knorton01

    Joined:
    Oct 17, 2017
    Posts:
    3
    After reading through a lot of the SomethingAweful posts, I have to ask how the idea of factions might be approached, while maintaining the idea of procedural ship generation. In other words, is there an optimal way of producing a wide variety of ships, with each ship having a distinguishable "style" or "class" or with your words, "DNA".

    What comes to my mind is either assigning a group or class of procedural ships a certain set of parts/polygons unique to that group--or assigning to that group a unique tree of possible orderings of parts/polygons (where the polygons are still available to all groups). Then there's probably a middle ground somewhere.

    However the idea is worked out, I look forward to the next SA post.
     
  45. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    There are model groups (Wings, Body, Cockpits). Some of them are heavily specialized (Wings_FactionX). These contain 20 to 30 models.

    There are also collections, to make my life easier. These have weighted values for groups, so a collection of "Assorted Appendages" may have a 30% chance of spawning a wing, 20% chance of spawning an antenna, etc.

    There are Ship Algorithms which are pointed from the ship type enum. So the reference for an EmpireFighter will refer to a specific algorithm. These algorithms are split into many functions, unrelated to each other. For example, AddWing() from an EmpireFighter may do something different than AddWing() from a RebelFighter.

    The DNA is a sequence of pointers, delegations and variables which define which function from where the ship is gonna use now. So a DNA may be a sequence of, say AddCockpit, AddBody, ExtendBody x4, AddWing, all referencing the EmpireFighter. However you could replace AddWing from EmpireFighter with AddWing from RebelFighter in the instructions, and now you have a DNA with mixed instructions.

    I'll detail it further in the thread, but hope it answered your question somewhat.
     
  46. ChristianLinnell

    ChristianLinnell

    Joined:
    Jan 7, 2013
    Posts:
    18
    Hey FPires, did you ever finish this procedural ship project? Those models look incredible. If it was on the store today I'd probably buy it.
     
  47. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,300
    Yes, this is really looking great :) I'd be interested, too. :D
     
  48. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
  49. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    58
    if you read his last message, he's posting development on his personal forums. he won't be releasing the code.
     
  50. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,300
    Okay then. I'll make my own :D
    Starting now.