Overlays + alpha

I’m using blender to make a game and I need to separate foreground and background objects. Currently I do this by tediously setting all materials of background objects alpha = 0, and rendering the entire scene, and cropping my desired object. However this is kludgy, plus it puts an outline of the sky color around the object which looks terrible in some cases.

Attached is an example of the composed result and the stupid outline ruining it.

What I need to do is render ONLY one object (or group of them) and leave the rest completely out of the scene with alpha=0 in the resulting image. However, they still need to affect the rendering (by casting light, shadows, ambient occlusion) so that the overlayed image will look exactly the same as it did when placed back into the scene. From what I can tell, layers won’t do this for me as it completely hides the other objects and their effects on the scene. Ideally, the edges of the “cut-out” objects would taper out with no color bias

Can anyone experienced enough with blender advise me on this?


Welcome to BA. I think what you are trying to do, can be accomplished by setting up different Render Layers. I have never done exactly what you are attempting, but here is the documentation on Render Layers, hopefully it will help:


I second what DichotomyMatt says. Also, note the buttons in the Scene->Render panels labeled [Sky][Premul][Key]. The sky setting is what causes the funny halos. Premul is probably the option that you want as it gets rid of the color bias caused by the sky.

I can also confirm that if a layer is selected to render but deselected in the render layer, objects in that layer still cast shadows and and affect ray-mirror and some other effects, though lights must be both in a selected layer and a selected render layer to affect the scene.

Also, I’m not sure exactly how you’ll be using these final results in your game, but be sure to check out Blender’s awesome compositor which works wonderfully together with render layers and render passes.


And finally, that is some awesome looking work you’re doing. And I would love to see more about what you’re doing in the artwork section of the forums if you’re interested.