Making Objects Fade In/Out - Cycles

I’m trying to make objects disappear or reappear in Cycles; I’ve tried three methods, but they all have disadvantages, and there’s a theoretical method that would have none of those, but probably isn’t possible with Cycles as it is now, and I do not know if it would be a simple change or not.

This is the current method that I am using:


A basic material (in the frame to the right) is mixed with a transparency shader by an input factor (also in the frame); if the face is backfacing or reached with a transmission ray (that’s the reason there’s a glass shader with an IOR of 1 in there,) the material is completely transparent.

The disadvantages are these: it interacts with glass shaders poorly. As you can see in the image, the part of the monkey seen through the glass panel should be only as faded as the part seen around the glass is; instead it simply isn’t there. I think there have also been issues with glass shaders being the input material; I don’t think they react well to having the backs of the objects vanish entirely.

The reasons these disadvantages matter is that the objects I want to make vanish may have glass parts; this creates artifacts in the image (like perfectly transparent holes behind any glass) that can be jarring.

An earlier method I’d used was this:


A basic material is mixed with a transparency shader by an input factor; nothing fancier than that.

The disadvantages are these: While the object doesn’t vanish immediately if seen through glass, rear-facing or internal geometry is visible through the front. That matters because it looks wrong; it’s obviously a product of the method used, and is not convincing to me.

I have experimented with this method:


The object I want to make disappear was isolated on a layer; two render layers were used, one including all layers, and one excluding the layer with the object, and the two rendered images were mixed together by a factor given by the value in the frame.

This method has neither of the disadvantages of the first two; it looks perfect, even through glass, and reacts just as well with glass materials being made to disappear.

It has many different disadvantages instead; it is resource-intensive, difficult to set up, and would be nightmarish to navigate for more complex arrangements. It requires the scene to be rendered twice; if I don’t do any magic with the per-render layer sample numbers, (and as keyframes or drivers cannot be added to those, that’s impractical,) the number of samples per scene (and thus the rendering time) are multiplied by the number of independently disappearing objects.
If the number of independently vanishing objects is greater than two, the node setup becomes much more complicated. Example: Object A is 3% visible; Object B is 70% visible. This means that three render layers are required, AB, _B, and __, each contributing 3%, 67%, and 30% to the final image, respectively. What’s the right arrangement of mix nodes for that situation?

And what if A is appearing and B is disappearing? A will pass B, becoming less transparent, and thus the second render layer will have to contain A alone, not B alone. The whole node arrangement has to change! I would have to do most of the work manually for each frame containing multiple disappearing objects; and that sort of repetitive computation seems to be something that a computer should be much better at.

Is there a way to get the results of the third method without having to set up node arrangements and sample numbers by hand every frame?

Is it possible to make an object only PARTIALLY visible to samples, so that, say, 3% of samples of that hypothetical scene include object A, while the other 97% are taken as if A is not there? (and the same with different numbers for B, but at the same time?)

The Ray Visibility tab under the object properties panel suggests no; object can currently be either completely visible or completely invisible to rays. Would it be a simple change to make this boolean into a float, so that we can make an object visible to 0.700 of camera rays, for example? Or is that a much bigger change than it sounds like, due to the way Cycles works?

If you know of any better way to deal with this situation, please let me know, and thanks in advance for any response I get.

If you are using the compositor to do this, you can set up a mask for your render layer, so that you only see the objects on a particular layer. Then you can use an alpha over to composite over the scene. If the objects that fade at different times don’t cross each other, then you can render them all together, and create separate masks for each object, and animate the fade out in the compositor.

If you do this, you can use the Render visibility tab to not see the object after you anticipate the fade to end, because then it would only be done to save on rendertimes (Although it might be better to only render as many frames of the vanishing object as needed, which can be done if you render the object in a seperate scene, that has all of the data linked).

SCENE 1 > Full render (RenderLayer1EverythingVisible) Entire Clip
SCENE 2 > Link Objects (RenderLayer2EverythingVisible with object mask, and shadow pass) Duration of the fade
SCENE 3 > Repeat Scene 2 for as many objects as needed.

Begin
Render Object in Background
Object Visible

Keyframe Begin Invisible
Begin Object in Scene 2
Animate Object Layer off in scene 1

Keyframe End Invisible.
Scene 2 is done rendering, continue rendering without contributions from the object

Composite it all together. If shadows are an issue then you might have to render scene 2 without a mask. I haven’t tested it in these circumstances, so you may or may not find that it helps.