roomyrooms

Hey!

I'm in the process of messing around with the spine unity runtimes and I was hoping I could get some insight on a few things with my clothing dye solution. This is the rundown of how the shader works:
1. Take an image, like so:


2. Isolate the parts of the image with the highest R, G, and B values.

3. Multiply those by a color, then combine those results into a "dyed" image, like so:


This works great and I can get it working in a few ways... the problem, though, is that I can't see a way to efficiently apply it to all of the skeleton's slots. If I use it as the skeleton's mesh's material, I won't be able to dye the sword separately from the shirt, for instance. But if I use custom slot materials, I'll end up with 20-40+ materials on a single skeleton with the potential for 30+ skeletons on screen at a given time.

... Obviously the performance on that is pretty terrible, but. I was hoping I could get some guidance on this. I was thinking (?) of sending this into the slot data (e.g. slot colors) but I'm not totally sure how to do that right now.

fwiw, part renderer separators don't really work either (shirts have slots above other parts of the body, etc. so dyes would clip through a ton of stuff and there'd need to be dozens of individual renderers, etc.)
roomyrooms
  • Postovi: 7

Jamez0r

Just to check - would Tint / Tint Black possibly work in any way? Like if your weapon images were actually separated into the individual pieces that the Comparison node is doing? Or is that not possible / too much work?

The only other thought I have is that, if you're using Unity's 2D Renderer, you could maybe look into the SRP Batcher. I can't remember specifically, so hopefully someone else can chime in, but I'm under the impression that one of the main benefits of the SRP Batcher is that it doesn't cause extra Draw Calls (or texture swaps, or whichever) if you render multiple things back-to-back that share the same material, regardless of Material Property Blocks, etc. Apologies ahead of time if I'm wrong about that.
Avatar
Jamez0r
  • Postovi: 358

Harald

Thanks for answering Jamez0r! 8)

SRP batching should work, since you are only changing material color properties at the materials.

A different shader-based solution would be to introduce an additional ID classification texture (such as the Substance Painter ID maps that assign different working materials at each texel). This texture would then have clearly distinguishable colors that associate each pixel with only one colorization-set, e.g. coloring violet classified texels with the sword color set, yellow classified texels with the shirt color set, and so on. Just be cautious with border regions where two colors meet, as blended colors might map to a third undesired ID color, so it might be easiest to just assign unblended ID colors.
Avatar
Harald

Harri
  • Postovi: 4101


Natrag na Unity