Search Unity

Fracture - Dynamic Destruction System

Discussion in 'Assets and Asset Store' started by smb02dunnal, Apr 5, 2013.

  1. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    $Fracture Logo.png

    I have finally got around to releasing my dynamic destruction system on the asset store. This system is ready to be used in your existing projects, and, in it's basic form, only requires you to drop a script on the objects you wish to destroy at run time, and your done.

    Here are some webplayer demos showcasing the power of the tool.

    Sticky Zones
    Field of Cubes
    Tower Stack
    Big Cubes


    A bit about the algorithm

    A predetermined number of random points are generated around the impact point (which is the center of the fracture). The number of points used, ultimately determines the amount of shards generated by the algorithm. The algorithm is voronoi based, so all the shards created will be of convex shape, which is perfect for MeshColliders.

    The computation can be performed immediately (see demos : 'Sticky Zones' or 'Tower Stack', or over X amount of frames (see demos : 'Big Cubes' or 'Field of Cubes').


    What comes with the package

    Firstly, you will get the above scenes and all the scripts necessary to start creating your own destructible environments, if that's not enough, I've also some documentation to help you further.

    Tools:
    Triggers, these are used to trigger the destruction on a particular object. They customize how the object can be destroyed. Whether its from collision impact, bullet hit or explosion damage, Triggers can be tailored to your exact needs in order to help you create than environment that crumbles around you the way you want it to.

    Sticky Zones, are used to hold broken fragments in place once an object has been destroyed (see : 'Sticky Zones'). Imaging shattering a pane of glass in a window frame. Some of the glass might stay in the window frame, sticky zones help you achieve this effect fast!

    Special Shaders. In order to keep the cost of the destruction computation to a minimum, I have created a set of custom shaders to be used with the destruction system. These shaders offload the work of UV-ing from the CPU to the GPU, helping parallelize the destruction and ultimately give you more of a performance boost.

    Cleanup Tools. Having too many destructible actors flying about can be very costly for the CPU (I am working on a GRB implementation but more about that later ;) ), so I have included a set of tools to help customize how destructible objects are cleaned up. There are currently two cleanup methods : destroying shards based on a timer and destroying shards based on how long they have been off-screen. Both can be used in conjunction with each other if you wish.

    All dynamic fragments are created from a pool, (it's not nesecary to create this pool in the editor, but I'd recommend it!), which helps with the amount of objects instantiated at run time.


    Any way, I hope you enjoy this tool, and if you have any questions please ask! :)



    Showcase

    Want to see your demo here? PM me.


    Tutorials

    Beginner:

    Getting Started:

    Convex Fracture:



    Intermediate:
    Performance Tips:



    Advanced:
    Structural Simulation:




    Asset Store
    Fracture - Pro (faster algorithm, with source, and support)
    Fracture - LITE (without source)
     

    Attached Files:

    Last edited: May 2, 2015
  2. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    Might want to fix those links, they start with http//
     
  3. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Thank you :)
     
  4. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    Might have to buy this, looks like an awesome little tool :)
    Any chance this works on mobiles?
     
  5. L-Tyrosine

    L-Tyrosine

    Joined:
    Apr 27, 2011
    Posts:
    305
    Amazing work, really impressive.
     
  6. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Cool. Fun to play with. I take it this couldn't really be applied to an entire game environment, too much physics etc?
     
  7. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Awesome. Depending on how this performs, I might be picking it up. My game needs something like this, if not this very thing. Good work. I hope people continue to make things like this. We need destructible stuffs already Unity! :cool:

    I too, am worried about performance. For instance, the tower example is fractured, but in big chunks. What happens as you multiply "pieces". I'm assuming the limiting factor here is cpu power?

    I just read your asset store description, and it says it works only with Unity cubes. Can it work with say a triangular roof made in a separate 3d modeling program?
     
    Last edited: Apr 5, 2013
  8. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    It's pretty nice so far. However, I was hoping you would release a demo of a completely destroyable building. Is that possible with your system? Also, do you plan on continuing development?
     
  9. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    I doubt this would work on mobile, but I don't have mobile to test on so I really couldn't say.
    In the future, I plan on releasing an in editor tool that will enable you to pre-fracture geometry in the editor and use that (in conjunction with another script) at run time. I think this would have a much higher chance of working on mobile. :D


    Thank you!


    Yes, currently the real limiting factor is the built in physics, but with the clean up tools I have provided, plus some other ones I have planned for the future ;) you should be able to work around it. In the mean time, I am working on a GRB simulation to use in conjunction with the fracture toolset, but it would only work with DX11.


    Thanks alot! I agree with all that you say, and I will continuing to make destructible stuffs for Unity (or at least until they integrate APEX ;) )


    I have disabled multi generation fracture for this exact reason (damn limiting CPU power).


    Yes, this release only works with unity cubes, it wont handle the geometry you mentioned, but you could make a roof from cubes in engine ;)


    I know you have been following my threads for some time, and I'm sorry I haven't got around to doing this yet. But! This is next on my todo list! Expect a demo shortly (and excuse my crude building model).


    Thanks every one for your support!
     
  10. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    This looks pretty awesome, however it is not very usefull (atleast for me) if we can not apply it to our own meshes. Building everything out of unity cubes is not only frustrating, but also achieves much worse results.
     
  11. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    This is box destruction, it's just for boxes... It has it's limitations, but it's not intended for a fully destructible environment.

    Very soon though, I will be replacing box destruction with something else I have been working on. Here's a demo:
    Columns Demo

    Although this demo is only using unity cylinders, you can plug your own mesh into it quite easily. It's already as fast at fracturing boxes as it's box counterpart.

    Hopefully this will suit your needs :D
     
  12. SinisterMephisto

    SinisterMephisto

    Joined:
    Feb 18, 2011
    Posts:
    179
    Will you try gibbing as well? (Dismembered body parts).
     
  13. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    I haven't made any plans for it, but it sounds fun! Might give it a shot at some point :)
     
  14. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Is it something like this you are after?

    $Destroyed Building.png


    It's not quite ready yet, but very soon! :D
     
  15. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Here is my latest demo, it includes a very first pass on automatic structural integrity. The system uses physics joints to connect a mesh that is uniformly voronoi decomposed as a preprocess, then the dynamic fracture works on top of that.

    The only problem is that the wall looks like it's made of jelly :mrgreen: FAIL!

    Next step is to come up with my own, much simpler, joint system that will give the appearance that walls are solid until they get destroyed.

    Here is the demo so you can see for yourself what I'm talking about.
    Destructable Wall
     
  16. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    Yeah, that's getting closer to what I was visualizing. However, I'm concerned about using joints though because I tried attempting it before. It was pretty good with just a single building in the scene. But when I tried to apply it to a big airship frame it lagged extremely. I assume similar results would happen if I tried to apply joint destruction to every building in a city. By the way, do you plan on adding a level of detail system to yours?

    The cylinder demo is promising as well. They are just to brittle. They need to be much stronger so they dont shatter as easily.

    You gave me a renewed interest in using joints for destruction. When I get the time I will do some more test!
     
  17. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    The more and more I think about it, the more I realize that solely using the joints unity provides, will never work for this kind of thing. Everything must be an active rigidbody, and that just wont cut it for big scenes.

    The system I am currently working on, avoids this problem and will provide a much more realistic approach.

    This is just tweaking settings on the objects from the editor. Of course, it's personal preference.

    Don't, it's rubbish :D



    In other news, the new version of this script has just been accepted by the asset store people. It took a while longer than I was expecting, but for those of you with the current version, the upgrade is MUCH needed! :D
     
  18. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Here's a new demo showcasing improvements from the previous one.

    Structure Demo
     
  19. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    This is sooooo Cool :D
     
  20. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    This one is way better. However there's a few problems I saw. First the structure can hold for to long when the area underneath it is destroyed. It should collapse once the support underneath it becomes weak enough. 2nd, when a piece of the structure falls off because the area underneath it is destroyed, it should not shatter before it hits the ground. It should fall off as one big piece. And last is the frame rate. Once the whole building was destroyed, the frame rate was down to 3 fps. A suggestion is to perhaps make the pieces that fell to the ground static? Or maybe just have them fall through the ground and get deleted.

    Great work! This is the best destruction I've seen for Unity so far. Hopefully it turns out.
     
  21. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    Damn i want some whoppers now.

    Anyway, this is really nice.. I will very likely be able to find a use for this in the near future.

    What are the differences between Pro and LITE? It says support and faster algorithms - is LITE not regularly maintained and Pro is?
    How does this handle more complex shapes? Can it - within reasonable framerate?
    Can the breakdown be rendered and saved instead of procedurally done at runtime? This would be handy for making cutscenes or something that can only be destroyed one way and doesnt need procedural variance.
     
  22. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    You're completely right on all accounts, I was aware of these problems before I updated, except the last one. I didn't get the frame-rate drop, it must be the amount of CPU bound rigidbodies.

    I'll let you know when it's updated!


    Yeah, basically LITE isn't maintained as regularly as pro, and you don't get any sourcecode. The features you mentioned are in the works though, although the offline fracture tool wont be ready for next update. The convex destruction tool will be ready and will completely replace the box destruction component. This will allow you to fracture more complex meshes (up to a degree of complexity).
     
  23. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    I have a new demo and video to show you.

    I have made some major performance increases to the joint system, plus added in some cool features like explosions :D check it out.



    And heres the link to the new webplayer:
    Demo
     
  24. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    Yeeaaaaahhhh I'm pretty sure I'm getting this.

    ..... Yeuuup.
     
  25. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    The frame rate appears to lag when there's a lot of large fragments in the scene. If I destroy them into smaller fragments, the frame rate goes up again. I noticed the frame rate is best at the very beginning, when the structure is fully intact, and when its completely destroyed, into 1000+ shards.
     
  26. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    Are the shards customizable? As far as the rigidbody setup controls (turning off gravity for instance) or if I wanted to put a tag/layer/script on all of the shards is that possible?
     
  27. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    This is really effing awesome! Great job man! Going to be buying this for sure.
     
  28. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439

    Yes this is possible, although it isn't explained anywhere (I'll add it to the docs). All you will have to do is either create a script that will listen for the OnPostDestruction callback and do your logic there, or, add the tag/layer/script to the shards in the shard pool.

    It's worth mentioning that the shards will retain certain properties of the object they belonged to, like tag and layer. I can look into adding more of these features if you'd like?
     
  29. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439

    The most recent demo's aren't included in the version currently on the asset store. But they should be soon, I will keep you informed if you like?
     
  30. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    I doubt I lack the ability to add on to your scripting. I generally just read through scripts and use playmaker to change variables and run functions on the fly.

    If the shards retain the info of the parent I could probably adjust that to do what I need. You say it's possible so that should be fine, I'm not in any time constraint to implement the fracture stuff. I'll grab it tonight and have a look to see, then I'll know specifically if I can/can't do something.

    Thanks
     
  31. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    I'm very interested in working with anyone without scripting knowledge to make this tool more useful, so please share, thanks!
     
  32. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Got a new demo, real time fracture of closed concave meshes, with UV and normal re-mapping.
    Mmm Donuts

    I doubt it will make it into the final product however, it's just too slow to pull off, and once you start using more complex meshes this method fails, as it doesn't involve any island checking. But it looks pretty sweet! No pun intended.

    It will most likely end up becoming the offline fracture tool, which you can use to pre-destroy your meshes inside unity.

    And in case anyone is interested and a major geek (like me), I found this link to an amazing paper from Matthias Mueller, demonstrating his technique for run-time fracture.
    http://www.matthiasmueller.info/publications/fractureSG2013.pdf
     
    Last edited: Apr 26, 2013
  33. Deleted User

    Deleted User

    Guest

    Well, I spent the last half an hour trying to break it. It is quite a system!

    If you are interested, this is what I was able to achieve.
    http://puu.sh/2Hyyy.jpg
    http://puu.sh/2Hyz0.jpg

    Whole building supported by a little corner. Half the building held up by a fractured wall corner.
     
  34. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    http://dl.dropboxusercontent.com/u/38606641/Brevis/BrevisFrac/BrevisWeb.html

    Theres some buttons you can press there.

    It seems like the very first few fractures are always handled poorly, after a few go through it starts to work smoother. Not sure why, kinda weird. I tried dropping some boxes onto that box tower and it chugged at the first start, then blows through with the big ball decently. If I remove the cubes from doing that first contact then its slower when the big balls hit the tower. Like it has to wake up the engine or something with a few hits. Maybe its the editor?

    -edit
    It seems to be pausing to compute when it is time to fracture more than 30 fragments or so. Big or small objects. How is the mass figured out? I noticed it divides the volume by the number of shards but doesnt account for how big the shard is, on the large cube shattering it breaks into 80 fragments at 6.25 mass but most of the fragments are tiny and there are 3 or 4 HUGE ones and all of them with the same mass. Seems like this would be fine for smaller fractures and groups of smaller fractures but on large objects it doesnt work as well.

    Maybe there should be an option to control the disparity in the size of shards?

    It may be helpful to pre-process some objects. As in just unmerging them when its time to break apart. Not sure how this would work though...

    As far as user friendliness this is super simple, just drag the script on, smash it and go about your business.

    Is the Options checkbox - Use Tag Of This Object supposed to make the shards inherit the parent tag? It doesn't seem to be working for me the shards are all untagged while the parent is tagged.
     
    Last edited: Apr 26, 2013
  35. gustavolsson

    gustavolsson

    Joined:
    Jan 14, 2011
    Posts:
    339
  36. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Hi, thanks for testing my tool!

    As a first pass I simply used boolean connectivity for structural integrity, next iteration will include more advanced techniques.
     
  37. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    The first object that is destroyed is slow, this is due to the JIT compiler creating and caching the code first time round. This is just how any JIT compiled language works. Since I have added an optional background step, that will destroy a dummy object on awake, and hence trick the compiler into thinking ahead of time.

    Just now, shards equally share the total mass of the destructible object they came from. If I'm honest with you, its a mistake, something I quickly put in a long time ago and completely forgot about, so now I'm using bounding volumes to calculate mass. It's far from perfect, but it works a bit better. In a later release, I plan to include GRB, which is becoming more and more stable right now. When using GRB, I must calculate the inertia tensor matrix for each shard myself, inside the same calculation I can easily slip in a precise volume calculation, which will give much better results in terms of calculating mass.

    I would recommend not calculating 30 shards immediately, thats going to be slow! Instead I would calculate it over X amount of frames.

    The Options checkbox - Use Tag Of This Object, is a bug, and since fixed. Thanks for that :)
     
  38. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439


    Thanks!

    Rather than creating any objects at run time, I try and minimize expensive creation costs by using a pool of pre-instanced, blank objects.
     
  39. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    How did you learn how to do this? Are there any material on the internet?
     
  40. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    A lot of it's just figured out from self taught stuff. I read lots of papers, also have a degree in computer games tech (although it wasn't particularly useful in this case) and I'm employed in the industry so i get to practice every day at just making S*** basically.

    Check out the portfolio if you like: http://www.dunnalex.com/

    I'm happy to help anyone understand as much as possible, any specific questions?
     
  41. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    I'm just amazed at how your able to do this. I've made a few attempts at understanding how meshes work, but it's extremely hard to wrap my mind around. Plus there's very little information on it. The best attempt I made was this http://www.youtube.com/watch?v=zQxL90PyhnM. However, I've managed to make a destruction system using pre fragmented models, and using a script to count how many pieces need to get destroyed on a floor before a building collapses. Its pretty simple and straightforward.

    If your system turns out though, I will definitely consider switching over to yours. If only it can handle lots of buildings in a scene, like a cityscape.
     
  42. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,526
    I'm pretty happy with it so far. There's a lot of room for continued development but its actually pretty impressive, I don't think you could destroy a cityscape of buildings unless you choreographed it a little bit because the volume would simply be too much but depending on your position, sequencing and fragment count you could definitely do that in its current state by adding in some graphical tricks. It can only really manage about 15 fragments smoothly without any hiccups so if you were stacking those every second or so it would likely be able to do it.
     
  43. tombali

    tombali

    Joined:
    Jun 7, 2012
    Posts:
    132
    Hi, this tool is great :) When can we expect update that will allow non-cube meshes fracture?
     
  44. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    I'm hesitant to use it because of a few specific things. Such as, do the fragments have any kind of poly reduction when viewed from far away? And can the fragment peices get combined so they dont create so many draw calls? This would probably be required for a large cityscape. Also, I have not seen a complete building model in the demos that is modeled and textured, so I cant tell if it will work with other than a greyscale object. What about windows on the building? Could they fragment in much smaller peices than the structure of the building?

    It just sounds to good to be true.
     
  45. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439

    Sorry I've been away for so long, I've been on the job hunt and busy with other projects. I'm back!

    There is no poly reduction when viewed from far away. There is no need to, all my algorithms produce optimal meshes, reducing them further would lead to very noticeable artifacts! However, I can implement this at some point to show you.

    As for the building, it is actually textured, I just put a normal map on it.

    And, about combining, DX11 is easy, either by using dummy CPU rigidbodies and instancing, or with GRB. <DX11 however, I have a plan. When rigidbodies goto sleep, I can add the mesh to a queue to become combined, and perform the combine when there is some free time. This will make the mesh static, and consume only a single draw call.

    Worth mentioning aswell, if you set your scene up to use dynamic batching, this will work with my system (at least it does in the building demo I published).

    Hopefully I am going to have a new version out by the end of this week.
     
  46. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    Hello, thanks for the reply.

    This question is totally insane, but I must ask to know how far the system can go. If there was a game with a map like the image below, Could it simulate destruction for every building in the scene with interior? Or better yet, how many buildings could it handle before it can handle no more?
     

    Attached Files:

  47. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    The only thing holding in most cases it back would be the CPU bound rigidbodies, but obviously it depends on geometric complexity and other factors as well. I'm assuming you've already fixed all the normal problems associated with rendering a scene of that complexity, and you have plenty of processing power left to destroy it.
     
  48. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    So would you say using this system is much quicker than pre fragmenting models in a 3d app? Also in my game, there are buildings with certain functions. If they get destroyed enough, such as a factory, it stops producing units. How can I tell with your system when a building has been destroyed enough in order for its function to cease? Also, how can different sound effects play depending on the destruction of the building? An example is a building that had critical supports destroyed and is falling completely to the ground. Can a sound effect be played that is suppost to be a large structure falling to the ground, instead of just a small rubble sound that would play if it only got hit by a small cannon?
     
  49. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Dude...this rocks!!! And i may use it for future projects and games. And the explosion DEFINITELY on point... I also see some potential issues for lighting a scene using GI and IBL. Are the pieces useable with light probes even after the damage is done?

    EDIT: Also my framerate dips into the teens when I completely destroy a structure while the particles are on screen. Running on a 3630-m and a GTX670. And some of these demos drop to 4 fps when I employ flatten. Also I think the breaks in some of these are too clean...
     
    Last edited: May 23, 2013
  50. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    Hey guys, thats the new version up!

    New features include:
    • Runtime dynamic fracture of convex meshes
    • Boolean structural integrity

    Also, I'm in the process of making the LITE version free of charge, just waiting for the confirmation, so if you want to try Fracture out, I'd wait a few days at least :D

    Enjoy.