I've been looking for some sort of way of rendering invisible objects as transparent pixels depending if they're in front or back of visible objects in the scene.
For example, I have a clothed character like this:
And my goal is to render every clothing attached to the character independently, this is for making a spritesheet I can use in a 2D game but I have a problem with that and is that when I try to snap a single clothing, some parts that should be hidden by the character body itself are being renderer.
IE: let's say I want to render the character's hair only, when I take the snapshot I get something like this:
As you can see, there is a part of the hair I wouldn't like to be rendered after all, like the part where the character's face should be:
I've been thinking of simple hacks like making some sort of chroma by using a green background and a green texture in the head, so then I can use a tool like Photoshop or Gimp for replacing the green part with transparency, but I'd like to make it in a simple and faster way if possible.
The sprites are going to be produced in a automated way by using a Python script, I also use Cycles as my rendering engine for this purpose.