-
Checking to see which ‘side’ of a layer the camera’s seeing…
Hi all.
I know that there are plenty of work-arounds to this – parenting with a 1 pixel seperation in the z axis etc, but (for the sake of expanding my knowledge regarding expressions) humour me, if you will…
Imagine I have a comp containing 2 layers running the length of the entire precomp – for the sake of argument let’s say that they’re a ‘front_face’ and a parented ‘back_face’ of a playing card. If the ‘front-face’s opacity is at 100, then the ‘back-face’s is automatically set to 0 with the expression:
if(thisComp.layer(“front_face”).opacity == 0) 100 else 0
applied to the opacity parameter of the ‘back-face’.
Here’s the tricky part – getting the opacity of the ‘front_face’ to pop to 0 when it has ‘turned away’ from the camera and thereby triggering the opacity of the ‘back_face’ to pop to 100 and take over. Okay, if we assume that the layer only rotates once in the Y axis, and that it’s sitting directly in front of the camera (and that the camera isn’t rotated off axis in any way) then it’d be fairly straight forward – I guess you’d use the expression:
if(rotationY < 90) 100 else if(rotationY > 270) 100 else 0
on the opacity parameter of the ‘front_face’ (no doubt there’s a better way of expressing this, but for all intents and purposes I’m pretty much an expression newbie…)
As we all know, things aren’t always as straighforward as layers rotaing just the once in only one axis, and once you’ve added a moving camera into the mix it gets ever more complicated – so here’s the crux of my question – is there an expression that looks something like layerFront=visible or do we need to get into complicated formulae testing for a layers orientation relative to the camera?
Apologies for the long-winded nature of this post, and yes, I understand that using an expression to tackle this sort of elementary problem is a bit sledgehammer/nut, but I thought it’d be interesting to see how it’s done.
Ahem. At the risk of looking foolish when Dan comes back with a solve-all one line piece of code…
Warmest regards.