Another long technical post. Studio work brings it out in me. This one is for Rich.
Been working for the last few weeks on a big broadcast thing (can't say what). But came across a situation in Maya that I've come across a few time before and never had a good solution for. It's probably that I'm just dense and there is an easy solution, and I've certainly never researched it extensively, but it's kind of annoying. Here's the situation:
I have a circular object (or a sphere, or a spiral or whatever) and I need it flowing or spinning around an object. Normally, not a problem, I'd just put the center object (or a card with video of the object) in the 3D scene and render it that way. Just did that recently on shot with faces inside 3D bubbles. But often, as is the case here, the video that needs to go inside (or sandwiched between) the 3D object(s), needs to be put there by someone else after the 3D render, in the edit.
In this case we've got clips of talent and video that hasn't even been shot yet, let alone color corrected or finalized in any way. So I need to somehow make a tool kit that allows for things to go IN FRONT OF AND BEHIND ONE OBJECT AT THE SAME TIME in an easy way that an Avid editor can do without much instruction from me.
Example. How do I comp this assuming things are moving around and flowing, etc.
The most obvious way is to just mask things by hand (ie. lay the 3D on top and mask out the back sections). But in these shots I'm working on, there are LOTS of pieces and they're all spinning and moving,etc. Don't want to ask someone else to do it and I definitely don't want to get stuck with it. The other solution is to just reframe stuff or change the shots. That would make me feel JV, and wasn't really an option here.
So I thought about for a few minutes and came up with two solutions, both kind of similar, but slightly different in terms of workflow:
1) create a depth shader for the 3D objects that is binary. That is, beyond a certain distance it's black and in front of that distance it's white. Then I'd render the scene normally and use the output of the shader to mask either the front or the back.
2) use the camera clipping planes to chop the render in half and render two separate passes, one for the front half and one for the back half.
I ended up choosing route #2 because it seemed to be the easier thing to pass off to the guys in post. I also KNOW what will come out, basically. The renders on this project are relatively simple, etc, so I think it'll work just fine. I think there are advantages to both methods, and I suspect now that the depth based solution would be the more robust one in many cases, but granting that, here's how I created a workable solution:
As I said, the objects and cameras are moving around, so I needed something a bit more flexible than just typing in numbers. I wrote a script that creates a distance tool between an object (can be whatever transform you want) and the camera. The script just uses some conditional nodes to pump in the distance to the object's pivot to the far and near clipping planes and switches them based on an attribute in a null group. So I can just select the circle (or a locator parented to the circle) and the camera and run the script. Then I set up render layers with the switch set to "near" and then "far" and render the two layers. I get the scene rendered with just the front and then just the back and I can just hand off those two renders.
In post you just sandwich some video in between these two renders. Easy to understand, I hope, for the editors.
Here's the script I wrote: zbw_splitPlane.mel
Some limitations of my method (which is why I'll probably redo it the masking method, at some point) are that you won't get reflections (I don't think) from objects in front of the split plane. Not really a problem in my shots, cuz there's almost no reflection and things are really zipping around.
The only thing I could see possibly going wrong the masking/depth method would be that things crossing (front/back) could create issues when you actually want to see something in back, but it is occluded by an object in front. There would be no way to get images of JUST the things in back.
Anyways, if anyone has any other thoughts or ideas or solutions for this type of thing, I'd love to hear them.
As always, re: scripts, my code is inelegant and usually just me hunting and pecking around for ideas that work. Don't judge me, just love me.