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:

enter image description here

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:

enter image description here

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:

enter image description here

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.

Thank you...


Using render layers might help you. I have created these two planes, and put them in seperate layers. The light grey in layer 1, and the blue in layer 2. In the render layer tab settings there is a "mask layer" where I chose layer 2 as a mask layer.

enter image description here

Please note that the shadows of layer 1 still render, you can remove these by unchecking the "shadow" box in the "cycles settings" under the object tabenter image description here

finished result, a masked grey plane in all its gloryenter image description here

If the blue plane on top is moved below the grey plane. It will not mask the plane.

|improve this answer|||||
  • $\begingroup$ Hello and thank you for your answer, I've never used render layers before but this time I noticed how useful and powerful they are, your solution is the correct, however it only worked with Blender Render though and not with Cycles (guess there should be some nodes settings to work on maybe?), but anyway, since my materials weren't that advanced and they were shadeless I decided to switch back to Blender Render to test and voila! they're masked perfectly, have a great night! $\endgroup$ – Edgar Alexander Sep 9 '18 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.