Search Unity

Question Realtime mesh cutting??

Discussion in 'Scripting' started by Davood_Kharmanzar, Sep 4, 2021.

  1. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411


    hi, this project was made by UE ...
    so, how can i do this in unity?? i mean realtime mesh cutting ...
    does exists any github or scripts or plugins or something to do that?
    any suggestions?
    thanks.
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    I dont think you will find a ready made solution for exactly that. But is exactly that what you want? Or do you need something else and that was just an example? Mesh cutting, or realtime mesh alteration in general, is a highly advanced and complex topic.
    There are tons of assets for cutting through objects, ie turning one object into two. You could use one and (heavily) alter the code to how you need it. Or if you really need exactly what is shown in the video.. you can cheat a lot. You could just remove connections and push the mesh apart around the scalpel, and then put some object behind it for the interior texture. However, if you then want to cut pieces out of the mesh (ie want to cut the arm off), that's not a viable approach. A solution for one usecase may involve cheats to make it easier that make it unusable for another usecase.
    • It depends on what you need, specifically. A lot.
    • I dont think youll find a ready made solution for exactly your use case
    • As soon as you need to alter an existing solution or write your own, be aware that it's an advanced topic
     
    orionsyndrome likes this.
  3. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,105
    it does appear like some sort of cloth simulation, this one in the video. if so, it's pretty creative.
     
  4. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
  5. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,105
    to be honest, I find all of this really gruesome. if someone made an ordinary game like this, the world would be in shock.

    but nvm I understand it's just the reality of invasive medicine -- anyway, this tech seems to have been developed with a lot of money, and whoever made it knew exactly why this made a perfect business sense. so it's hard to glance over a know-how of that size and jump to conclusions with some "ah yes, you can do this if you hold here, and staple there"

    nah, won't be that easy. I can only reiterate what Yoreki already said, he was spot on.
     
    Yoreki likes this.
  6. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    so,
    is it very hard to do that with unity?
    or its impossible to do with unity?
     
  7. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Why would it be impossible?
    Of course it's possible. It's not easy. It wasn't easy for the people who made Precision Tech, it won't be easy for you.
    No matter what engine you are using. Unity gives you the tools, you have all it's APIs and C#. The rest is on you.
     
  8. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    it would be better to say EA Games and Epic Games peoples ...
     
  9. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Not really, it was made by precisionOS. When a game mechanic is made, you don't credit the general purpose engine, you credit the game developers who created said mechanic.
    They might provide APIs that would help implement said mechanic.
    Other than that, it has little to do with epic. Unless said cutting technology is provided out of the box with the engine.
     
    Last edited: Sep 5, 2021
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    To achieve a similar effect CAN be pretty trivial - you don't really cut, you generate a mask. Similar to texture painting, and then this render texture mask provides the alpha that the dissolve or cutout shader on the skin needs.

    This is the most basic form and can be polished to a high standard with additional shader work.


    If you want an even EASIER time, for now, do it on a high poly mesh and just set vertex alpha. Then the cutout shader can grab a decent vert colour alpha value and drive that to discard pixels.

    This is for a most primitive test and if it's good you can move onto higher resolution texture approaches. All of this and runtime texture painting is well researched in Unity with many free assets and githubs, blogs covering basic texture painting.
     
  11. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    thanks for your response ...
    but what about pressure interacting? this virtual human skin was interacted with pressure!!

    and what about this mesh sewing??
    seems that this made with unity by ubisoft ... i think

    https://previewlabs.com/surgical-simulation-prototype-for-skysurgery/
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If you go the mesh approach you're going to be alone and have to deal with a very hard job. Look up cloth tearing and repair on gpu with compute shaders for a start.

    It's entirely up to you if you'd like to go that way instead of an easier route.
     
    orionsyndrome likes this.
  13. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Maybe that's just me, but i'm still not sure what it is you are actually trying to do. When i asked last time you only posted additional information about the reference project, but did not actually answer the question. It made clearer what you are talking about, but not why or what you actually intend to do.
    So do you want to 1:1 copy the reference project? What for? If you want to use something like that, it already exists - namely the project you posted. Do you want to try implementing it for learning purposes? Do you need parts of it for a game you are working on? Do you want to make your own medical simulator? If so what features specifically does it need to have?

    These are important things to know, as the answers may enable you to take huge shortcuts. For example, if you only need the feature to cut skin, you could do what i wrote above, ot use shaders to get a similar effect as was suggested by hippocoder.
    If, however, you intend to reproduce the entire capabilities of the project shown.. dont. You are talking about an insanely complex, cutting edge project that probably involved tons of money and a decently sized development team. Even if you are confident in your abilities to tackle complex topics and your ability to stay interrested in the topic for that long, as a single developer we are talking about years - especially since you dont seem to have previous experience with realtime mesh alterations. Depending on the exact scope of the project possibly even longer.

    So i'm asking again: what exactly are you trying to achieve and what for? For any part of this we may come up with cheats to make it a lot easier and quicker. If you want to make a full on surgical simulation.. it is simply a complex topic and will take its time.
     
  14. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    thanks for your response ...
    i want to cut / sewing small jelly plane or jelly sphere or jelly cube or fruit with knife ...
    something like as that human skin ...
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use one mesh as skin, and another mesh as the inside, and use texture painting on the outside mesh to mask holes or cuts. This is the least friction possible that I know of, be happy if someone could think of a simpler method.
     
  16. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Just to get this right. Imagine i had an object. You want to be able to:
    • Make a cut, see interior
    • Sew this cut together again - not looking like it originally did, but sewed (?)
    • Cut of a part off the object, ie turning a sphere into two halves (??)
    • Sew cut off parts back on to the sphere (??)
    For the first one you could fake it rather easily. The second one can be added rather easily as well. For the third one on its own there are many assets, but combining it with the above is harder. Combining all 4 would be hardest, not to mention if i missed some usecases you are looking forward to do.
     
  17. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    i have a balloon that i want to cutting their surface [not slicing it to parts] to put something in that and then sewing their surface ...
     
  18. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Please provide at least one path you have tried or be more specific about how much detail you'd need?
     
  19. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    i think have to hire unity team for that :]
     
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yes to be honest, its a huge job. But you can get 99% of the way there with open source texture painting stuff. The alpha cuts the hole and closes it again.
     
  21. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
  22. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    Last edited: Apr 3, 2023