Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Is there a good approach to implementing battle damage to clothes?

Discussion in 'General Discussion' started by dvnexus, Apr 2, 2021.

  1. dvnexus

    dvnexus

    Joined:
    Jan 18, 2021
    Posts:
    19
    Is there a good approach to having battle damage in your player character?

    Like... is it easier to just swap the model with the damaged version/s

    or is it better to have damaged alternatives to the armor/clothes the model is wearing?

    If you have a good method the former, I'd love to hear it.
     
  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    One thing you could do is make a shader with transparency (perhaps Alpha Cutoff) and use the alpha channel to simulate tears in the clothing or holes in the armor kind of thing.

    That's probably at least the more efficient and speedy way to do it - doesn't look as good of course.
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    9,136
    It, depends on the game. Basically approaches that exist are:

    1. Swap models.
    2. Swap materials
    3. Alpha-cutout texture for holes.
    4. Actually alter cloth model (haven't seen this one for a while. It was present in blood rayne 1 where you could slice environment cloth per-vertex).

    If you swap models, it will cause visible "jerk" in movement, as the new model will not inherit movement of the old.
    If you swap materials or implement "holes", then cloth will not behave completely correctly, as "torn" pieces will not be moving as if they're torn.
    And actually altering cloth model is difficult.
     
    Antypodish likes this.
  4. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    1,902
    You could also use stencil buffer to create the effect of chunks of meat missing etc
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    9,136
    Unless I'm missing something, that would be a royal pain to do in a scene with shadowcasting light sources. And an easier way to do that would likely to cull geometry through geometry shader, tesselator and then on pixel level.
     
  6. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    1,902
    That's true valve solved it with a blood texture were the alpha was used to kill pixels


    Screenshot_20210402-125111.jpg
     
    tmonestudio likes this.
  7. dvnexus

    dvnexus

    Joined:
    Jan 18, 2021
    Posts:
    19
    Would you say, swapping models will be easier since my transition to armor damage is an explosion and scattered material during the change?
     
  8. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,178
    Swapping may work for armor pieces. But say it is a forearm gauntlet and the sword strike is near the wrist, will you have a separate model for each strike zone or does that accuracy matter. Another method would be to find the strike points from the collision, get the local vertices and jitter them based on collision magnitude. A component that does this could be dropped on any number of collidable surfaces and sustain the damage after the collision.
     
  9. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    9,136
    The jerk of suddenly spawned cloth piece will be incredibly obvious. I wouldn't use this method.

    I'd either look into material swap or alpha cutout texture, or I would look into detaching pieces of cloth at runtime.

    Another possibility would be to destroy cloth parts completely as in remove it from the model, and spawn particle system to hide moment of disappearance.

    Like ippdev said, swapping would work better for rigid armor pieces. And not for clothes.
     
  10. dvnexus

    dvnexus

    Joined:
    Jan 18, 2021
    Posts:
    19
    Would you happen to know a good tutorial for this? I'll settle with cloth tears for now. I'll probably just add bullet scorch marks on the armor.
     
  11. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,804
    The simplest approach is take your texture into a paint program and simple erase areas with an eraser, save it out as a PNG (make it a different texture).

    And then in run time just load that texture onto the material.

    But sorry no tutorials, I'm sure you can find something about this with a google search or youtube.
     
  12. dvnexus

    dvnexus

    Joined:
    Jan 18, 2021
    Posts:
    19
    Okay thx! I'll look into it :)
     
  13. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    2,627
    Another cool thing you can do with alpha cut-off is make lots of rips with different transparency levels. Then, in the game, you can keep slowly lowering the cut-off threshold to reveal more and more damage.
     
  14. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    1,902
    And with property block in theory atleast you should he able to do it in one set pass
     
unityunity