Search Unity

[ASSET] SMITHY Procedural Generation Framework (gif heavy!)

Discussion in 'Works In Progress - Archive' started by beeftime, Sep 13, 2015.

  1. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Hello everyone,

    Last year I started working on an ARPG item generation framework. I finished, but I felt that, ultimately, it wasn’t good enough to release (let alone ask money for). Taking what I learned I started again from scratch a few months ago, now with a much better implementation. I also decided to break the project up into a few different assets that would work together, but would be useful and powerful on their own.

    A little while ago I released Selectionator, the weighted selection engine that will eventually be the RNG heart of the system, but is a useful asset for anyone that needs weighted random selections.

    After that, I started working on a procedural item model generator. As I’ve been working on it, it’s expanded into a full-on procedural content generator. It integrates nicely into Unity’s component system, and can be dropped into existing projects really easily, or can support new projects from the ground up. I’ve been calling it Smithy and I think that’s the name I’m going to stick with.

    It’s a bit involved, but to the end user there’s really not a lot to fiddle with (unless you want to, then there’s a bunch). Most of it happens in an adapter component:

    (there has been basically no UI work done so far, so I apologize for how rough this looks, for now at least)



    You throw it on a GameObject and drop it into edit mode. From here, you can define any number of nodes - plugs (fit into sockets) and sockets (accept nodes).



    You then tag these nodes with any keywords that might be useful. “Branch”, “Gun Barrel”, “Arm”, “Hilt”, etc. You add any number of tags, and overlap node tags on the same object. On generation, nodes find keyword matches from your assets (or AssetDatabases, if provided) to connect to.


    (You can see some of the first steps towards a not-godawful UI here)

    If your GameObject has a mesh, it’ll let you snap nodes to points on the geometry (vertices, triangle centroids, edge midpoints, and also at a mouse position raycast)



    These nodes have a fixed position relative to the object, and a facing direction (this is the angle it connects to something, or has something connect to it), as well as a percentage chance that the node will be filled (in the case of sockets) or selected (in the case of plugs) on generation.

    There are a few options that allow for precise and quick adjustment, like movement snapping and connection angle overrides (default connections are set to the normal of the mesh they’re attached to, or world.up for objects without a mesh)



    There are also jitter options. These will shift position, rotation, and scale on generation. This helps especially in making organic and greebly stuff look hand-made:



    (size jitter only)

    Nodes also have some QOL stuff built in - they can be arranged into layers that can be mass-adjusted. You can sort nodes into layers and set all their tags, weights, alignments, etc. all at once. Nodes and node layers can also be selectively hidden, and color and opacity options are in the works.

    Nodes can also have a weighted list of materials, and on generation will choose and take (or push to their child):


    The final node feature - and something I think is especially useful - is the inclusion of procedural materials. This was the last feature to get implemented, and so far it's working pretty well.
    Procedural materials consist of combinations of ShaderProperties and selection probabilities, and then choose from these combinations to fill out a newly-instanced material:


    These nine spheres are all referencing a single procedural material asset, which holds a few texture and glossiness options.


    Objects can be generated in-editor for testing, or for saving out to a unique own prefab. Nodes can be manually linked up or generated on the spot (single nodes or for the whole object). The greeble demonstration gif above is being generated and re-generated inside the editor. Generations here can also be saved into their own prefabs.

    One of the more useful aspects of the editor assembler is that it’ll take and spit out seeds. You can feed this to the generator at any point so you can generate the exact same object under any conditions. Multiplayer games, for instance, can ensure the same item drops for all players by transmitting the seed.

    Realtime generation happens through a factory class that can take parameters to further tweak the object that’s generated. There’s also a preloader script that can be dropped on objects already in the hierarchy to allow them to generate child hierarchies on Start(), which is useful for environmental/decorative stuff.

    ---

    So I think it’s pretty evident that this could be a nice resource for designers, artists, and teams with limited art budgets. What’s really exciting to me, though, is that because this system just bolts on to GameObjects, there’s nothing to stop you from throwing logic nodes in.

    One of the included demos that I’m working on is a simple FPS shooting range with randomly generated guns (like Borderlands). I tried a little proof of concept test and I was able to knock out a pretty robust weapon generator from scratch in a single morning. You could use this for pretty much anything though.

    Anyway, it’s basically done and working now, but it’s still pretty rough around the edges. Here are my plans going forward:
    • Styling / QOL
      This asset is pretty much feature complete for release one, but it’s still clunky in some parts and not at all user-friendly. I still need to do a first-pass refactor and optimization. I also need to make sure that the system is intuitive and easy to use, and it needs to look nice. I want to knock out at least a few more demos to do this, so I really start to get a feel for how it might be used in different pipelines, and what parts of the system need to be immediately at-hand.

    • Read-only Asset and Bake To Read-Only (post-release?)
      Asset artists should be able to use this as a resource to extend their work, and hopefully revitalize previously-released assets. I want asset artists to be able to incorporate Smithy, and release to every Asset Store consumer (not just my customers). I think what’s going to happen is that I’ll have a different release edition target specifically towards asset artists. This edition will be able to “bake” the Smithy adapter to a read-only version suitable for export.
      Unity users who get these assets can also download a free, read-only version of Smithy. They’ll be able to instantiate the artist’s assets, but not modify node structures.

    • Runtime Node Editor API (post-release?)
      One of the things I think would be really useful is the addition of an API for node management at runtime, so developers could turn the tools towards their players. You’d be able to implement build-your-own systems (like Loadout or Scraps or Blacklight) really easily. This might involve rewriting some of serialization stuff, definitely a lot of extension and friendlier method writing, and absolutely require high-quality documentation, speaking of…

    • Support is a huge thing for me, and especially when it comes to Unity assets: I’ve bought my share of poorly-documented stuff with no support to speak of. I am committed to being available to resolve issues as quickly as possible - but - I am a firm believer in ease of use and excellent documentation being better than the quickest support. I want to make sure the system is intuitive enough to not really need the docs, but having really thorough ones anyway. Walkthroughs, tutorials, and examples are going to be included as well.

    ---

    Demos &c:
    I have a little lowpoly tree generator that takes these meshes:

    and does this:


    I have this as a standalone demo for Windows, (available here if you want it, run it windowed) and I had wanted to get it out as a WebGL demo, but WebGL keeps acting up. I'll hammer that out soon.

    Still early for demos, but I'll post them here as they happen. WIP stuff will be posted here or @evilwizards

    ---

    I’ll keep adding to this thread as I work on the project (and answer any questions that might come up). I’m also at @evilwizards on twitter if you want to ask questions there (or do me a solid and retweet something!)

    Date and price are still being worked out.
     
  2. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Got to work on a decent UI for Smithy. I had originally wanted to do something a little more flat and modern, but it just looks weird against Unity's gradients. I may end up changing some stuff (especially the Edit Mode button), but here's where I got to by the end of the evening:



    A few notes on where I want to go in terms of UI/UX:
    • It's a little garish, but I want to keep consistent color themes across the majority of the asset. If you're working in Smithy, tags and tag-related icons should be light blue, plugs a dark orange, deletion tasks red, visibility tasks purple, etc etc. I'm going to try to reduce user cognitive load by keeping everything as color-coded as possible.
    • The little Mario block looking question mark boxes are links to the documentation website, keyed in to the correct page and anchor. The box on the tag icon will take you to .../Nodes.html#Tags, where the tag documentation is. The box in the upper right of the component inspector leads to the documentation for the Adapter.
    • One icon per concept. Plugs should never be represented by anything other than the plug glyph or the word "plug". This keeps things easy to read and easy to glance over. But, for clarification and new users
    • Everything has tooltips.
    In the next few days I'll be sharing more UI and QOL stuff.

    I'm going to be working on this almost exclusively for the next few days because digging through my Editor code lets me refactor as I go. Both are crucial, but at least I can post some UI progress shots.

    Thanks for looking!
     
    manpower13 likes this.
  3. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Rolling along with UI:

    All of those tooltip boxes are pulling from a localization database. I plan to launch in English, then add Korean a few weeks later. Hopefully Spanish and Chinese after that.

    Also a lot of refactoring got done today, but it's hard to make gifs from.I love it, though. I get into a really zen state when I'm untangling spaghetti code. Anyone else?
     
  4. Barachiel

    Barachiel

    Joined:
    Nov 25, 2012
    Posts:
    147
    I built something very similar a while back and have been using it for various projects, generating items, levels, and everything in between as needed.
    Mine was never intended for release though so it has almost no UI and is exceptionally clunky.

    This has a few more features and the UI and ease of use looks great. =)
     
  5. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Hey, thank you!
    Happy to hear that the UI is looking okay; two of my primary goals is to make it easy to integrate into a project and fun to mess around with. Too often assets like this are an uphill battle to coax them to do what they actually say they'll do. UI/UX is a pretty major component of that, so I've been spending a lot of time on it.


    I wish I had more stuff to post today, but it was mostly Editor code refactoring. Here's a few more buttons, though:

    (that enumpopup from a button is a gross little hack)
    I'm not sure how I feel about the small buttons and I may be changing them a bit for readability's sake.
    Also forgive the TODOs, haha, I'm still framing out my localization stuff.
     
  6. Barachiel

    Barachiel

    Joined:
    Nov 25, 2012
    Posts:
    147
    If it works the way it appears to it should be quite fun just playing around with it, and efficient when you know what you want to do. As I said, mine is rather clunky, I need to place my nodes manually which can take some time.

    With your probabilities for each possible item being spawned, are you displaying them (and allowing them to be edited) as a percentile compared to the other items, or allowing the user to provide arbitrary numbers for the weight and calculating the percentage to display for ease of use?

    With the UI, I think you're doing a good job of making their functions relatively obvious (and the tooltips solve any cases where this isn't true), but regarding the vibrant, possibly garish colors, have you tried desaturating some of them a little while still keeping the colors obvious?
    The color on the tag icons are great, for example, but the bright red on the trash icons and some of the other blues might stand out a little too strongly.
    This is just my opinion from a brief look at these images though and, much as I'd like to, I can't justify purchasing this when I have my own system, so don't go changing the UI just for me or anything. =P
     
  7. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Yeah, actually getting the UI set up, I'm seeing where my current ideas graphics-wise fall flat. Some are too busy and some of the icons (trash especially) overwhelm the color and don't read as clearly as they should. I think the sizes are good, though, so I think I'll keep them in until all the refactoring is done then swap them out for something a little more flat and modern (and hopefully readable)

    As far as the probabilities - the UI isn't there yet so it's currently unclear as to what's what. There's two different things going on:
    • Plugs being spawned into sockets are chosen from a pool, and are selected by weight (which is an arbitrary value set by the user).
    • Sockets are given a flat percentage chance to fill on generation. A socket with a probability value of 98.0 will spawn a plug node on generation 98% of the time.
    But right now the UI isn't communicating that clearly enough. Especially in the case of plugs it's not immediately obvious how "strong" a value is. One of the items further down the list on the UI pass is a Manager/Options menu, and it should be pretty easy to at least add some metrics.
    Also, on the Object Assembler (next up on the UI pass) I'll be adding a tool to check spawn rates. Investigating a socket node will give you a list of plug-bearing objects that can spawn, and their relative rates.
    This'll allow users to really dial in percentages (while still keeping the flexibility of arbitrary weights) but it's not great. I'm working out a few ways to get that feedback as part of the tag system. I'll have to prototype it first, though, so it's a little ways off.

    Thanks for the comments, too! Even if you have no plans to buy something like this it's really great to get feedback from another developer who has made their own.
     
  8. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    This looks incredible... Would it be able to procedurally generate weapons (such as clubs, spears, swords, or axes) at runtime?
     
  9. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Absolutely! That's actually it's original intent. Define your prefabs and they'll snap themselves together like Lego. :)

    Also because everything is just GameObjects linking themselves together it's easy to add logic and properties via script components.
    Once I work out the UI stuff I'm going to be starting on a simple fps demo to show how easy something like that would be.
     
    theANMATOR2b likes this.
  10. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    I would readily pay for something this, if I had the money [:p] Looking forward to it's release!
     
  11. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hey beef - great looking asset.
    I don't know how much work it would be on your end - but you may want to consider PlayMaker integration. I believe it would truly expand your prospective customer base.

    Looking forward to checking this out.
     
  12. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Thanks!
    I'm definitely interested in PlayMaker integration, but I'm not very familiar with the system. It's certainly well-documented, so I think it probably won't be too difficult to adapt, but it'll have to wait until after release.

    Anyway, I was getting frustrated with my UI, progress was slow, and the number of textures I needed started to balloon out of control. So, I took it back to the lab and basically tried to make Bootstrap for Unity Editor.
    And it mostly worked!
    There's still some rough edges but the difficult stuff is done and working nicely:

    Only one texture (a circle) necessary, everything else is built with rect placement. Graphically it's pretty much done (I still have to calculate color mixing so drop shadows/button depth doesn't look so janky).

    Buttons, panels, and jumbotrons are in. I should be able to knock out grids, button groups, progress bars, and toggle stuff in a few days. Not sure how I'll handle media, but I'll try.

    As it shows in the gif, I scrapped the help buttons, and instead just listen for ALT being held. The items that are getting a yellow highlight can be clicked, which opens up the help page, anchored to the relevant link (as in site/helpPage.html#helpItem).

    I'll release this (for free) once I polish it up a little for fellow editor asset authors
     
    Last edited: Sep 23, 2015
  13. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Yay! [:p] Procedural weapons/sculptures/combes here we come! [:p]
     
  14. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    The day job workload went nuts for a few days, so I wasn't able to get a ton done, but this whole weekend is blocked out for asset work. Here's what I'm working on currently:

    the code looks something like this (although still definitely WIP):

    Code (CSharp):
    1. //Button:
    2. Flat.Button("Default", Size.Small, Style.Default);
    3.  
    4. //Link button with badge:
    5. Flat.Button("Link style with Badges", Size.Small, Style.Link, "Nice!");
    6.  
    7. //Glyph:
    8. Glyphs.Glyph(rect, "fa-github", 50);
    9.  
    10. //Rotated glyph:
    11. Glyphs.Glyph(rect, "fa-github", 50, Direction.Down);
    Text color is managed through a static color (like GUI.color is). Buttons and badges scale to encapsulate content. Everything you see here is done via fonts and a circle texture, still. The FontAwesome glyphs you see are used the same way you'd use them on the web (ie, "fa-glyphname"). FontAwesome is the only one up now, but I'll be importing as many as I can find that have permissive licenses.

    Once I get all the features in, it's going up on GitHub. It might seem like a distraction now, but it'll be the entirety of the Smithy UI, which will not only help me finish much faster, but make updates and extensions much quicker.
    It's just good for the community, too. There are very few Assets targeting other Asset authors!
     
  15. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    This is really starting to shape up. Dropped a lot of the weird custom stuff I had going on and fell back on a solid GUISkin and the unity tools. Today I knocked out some of the typeface stuff and simple input boxes.
    Going to spend a few more days on popups/downs, tooltips, and panels, then back to cleaning up Smithy:
     
  16. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Calling it (kind of) on the editor bootstrap stuff. I've got a decent start set up for myself and tooled around with it enough to know what I have to do with Smithy's UI. I'll come back to it once Smithy is in testing, then maybe really polish it up once I've released:

    Still missing button groups, bootstrap-style tooltips, and dropdowns/ups and popups -- which it'll likely get once I implement them in Smithy -- but the repo is here: https://github.com/evilwizardstudios/UnityFlatEditor

    Back to Smithy proper, starting now.
     
  17. Barachiel

    Barachiel

    Joined:
    Nov 25, 2012
    Posts:
    147
    Well now, this might actually prompt me to make some of my editor scripts easier to use.
    Thanks! =)

    Are you just cleaning up Smithy's UI now? If so, does that mean you have it more or less feature complete, at least for an initial release?
     
  18. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Yep! The vast majority of the actual work is done. Here's my roadmap for the near future:
    • UI / Refactor
    • Demo / Example / Documentation
    • Optimization pass
    • Testing and bughunting
    • First Release
    So it's still a little ways off but I'm definitely in the home stretch. There's a handful of features I still want to add that haven't been implemented yet, but they're better left for after the initial release.

    However I'm going to have to travel due to work until mid October, so I'll be working when I can but updates are going to slow down temporarily for the next two or three weeks.
     
  19. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Still alive!
    I was abroad for work, and as soon as I got back they got me working remote (domestic, but still). Oh well. Only a few more months and this client will be out. I hope to be released before then, but if not I can dump tons and tons of time into Smithy :)

    Anyway, came back to roll out UIv3, taking what I've learned from my little Bootstrap thing. GIF incoming:

    I gotta find a screen recording setup that actually captures the mouse. Anyway, you can see the instant-response popups. Basically everything here is made from GUI.Boxes and rendering a glyphicons font directly, so it's nice and fast.
     
  20. dharmaone

    dharmaone

    Joined:
    Jan 22, 2016
    Posts:
    1
    this looks really cool. Any alpha available for testing?
     
  21. beeftime

    beeftime

    Joined:
    May 14, 2014
    Posts:
    43
    Hey, thanks!
    I'm in the middle of a first round of closed testing, which has uncovered a good deal of bugs and lead to a bunch of QoL improvements. Unfortunately none of it has made for good thread material. As it finishes I'll re-make this thread and be releasing demos until release.

    Right now I have a closed testing group of developers who I'm in close contact with. I may expand this group before release, and if so I'll ask for volunteers here and on twitter.