Lighting objects passing through a portal in Cycles I've created a portal based on this method. Here's what it looks like:



Light passing through the portal is not handled accurately; instead I've faked it by baking the light from the outside onto the outer side of the portal, and then applying the baked texture onto the inner side.

Now, the problem is that, as you can see, the two parts of the cylinder sticking through the portal do not match up, since they are lighted differently.

Is there any way I can get the light on the cylinder to work correctly?
Figured it out myself. It can be done by stacking three renders: At the bottom the interior of the portal, on the next level the exterior without the cylinder but with the shadow of the outer part of the cylinder, and finally on top the partially covered cylinder. The node setup looks like this:



And here's the result: