In my 2D platform game I have characters made of multiple separate pieces that can move independently in a hierarchy, so that I could move the limbs and head, change facial expressions etc., or add equipment or weapons they carry.
The problem is that when I make the character semi-transparent (like a ghost, or an "invisibility spell") by making the entire hierarchy transparent, their layering starts to be visible and the parts that has been hidden behind others suddenly start to be seen through other body parts :P (e.g. its body hidden behind clothes, or parts of the legs that are inside the body).
I would rather want the entire image of the character to become transparent, as a whole. (The way the character is built from separate sprites is an "implementation detail" that shouldn't be visible to the player, especially if it looks ugly :P )
Any ideas how could this be achieved?
I had an idea that I could first render the entire character into a texture and then display a simple rectangle with that texture applied, but that would probably complicate the rendering pipeline a lot, because it would require multiple stages before the character ultimately appears on the screen, and all of that for every character that would have to be rendered with transparency. So although it would probably work, I don't think it is the best idea. Are there any better ways to do it?
Side note: I want my characters to be customizable by the players, so that they could choose the skin colour, clothes, weapons & stuff. So I figured that I could make a base model in grey scale and then colourize it by changing the colour of the underlying mesh (kinda like those cheap lighting effects from the old days) or the texture mixing. But that of course requires some layering of all the component pieces of the character (e.g. outline and fill being separate, and interleaved for limbs and body so that the outlines were always underneath all the fill layers).
But this causes the same problem with transparency, because then the outlines might be seen through the fills. But I guess that if the transparency problem will be solved, this problem will go away too.