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. Dismiss Notice

Need help writing a shader for a breakable armor system in 2D

Discussion in 'Shaders' started by Yukken, Oct 8, 2021.

  1. Yukken

    Yukken

    Joined:
    Jul 12, 2015
    Posts:
    89
    I want to make a breakable armor(more like skin) system for a 2D game. It would be similar to a dissolve shader but broken parts simply get a different color.

    No limb destruction or anything like that. However, I need to be able to, say, break the armor at a certain point on the body. Armor within a certain radius would get broken.

    Ex: from gunshot.
    I'm not sure how I'd accomplish this. One thing I thought was:
    1. Divide the the body into small rectangles.
    2. Each rectangle had some float value denoting how much armor is intact.
    3. Fetch all of the rectangles within the radius and decrease thier values.
    4. Create/update a texture from rectangle values.
    5. Use it in dissolve shader.

    However, this is probably not viable for a spritesheet based 2D game because I'd need to micromanage rectangles for every sprite.

    Would it be possible to make a bonebased animation system work with a dissolve shader? Like, instead of rectangles, I'd save the armor values of each bone and somehow access in a shader. Is this possible?
    If not, I guess the other choice is to make the game 2.5D.
     
  2. Yukken

    Yukken

    Joined:
    Jul 12, 2015
    Posts:
    89
    Vertex colors make this easy for 3D so I guess that'll be good enough for a gameplay prototype.