Discussion:
Z Lighting Falloff or faking it with distance-based brightness/contrast?
(too old to reply)
N***@adobeforums.com
2008-09-29 18:47:29 UTC
Permalink
I'm having some trouble getting a light to fall off in the distance. Layers behind a light seem to receive the same amount of illumination no matter how far away the layer is in Z space. Is there something I'm missing?

If that's a limitation of AE lighting, could I fake falloff with an expression to decrease brightness based on the distance from the layer to the camera?

Here's the old Opacity to Camera Distance chesnut:

startFade = 500; // Start fade 500 pixels from camera.
endFade = 1500; // End fade 1500 pixels from camera.
try{ // Check whether there's a camera.
C = thisComp.activeCamera.toWorld([0,0,0]);
}catch(err){ // No camera, so assume 50mm.
w = thisComp.width * thisComp.pixelAspect;
z = (w/2)/Math.tan(degreesToRadians(19.799));
C = [0,0,-z];
}
P = toWorld(anchorPoint);
d = length(C,P);
linear(d,startFade,endFade,100,0)

How would I modify that to work on the Brightness/Contrast plug-in? Is there a better looking way? Exposure plug-in maybe?
S***@adobeforums.com
2008-09-29 20:18:07 UTC
Permalink
Unfortunately there is no falloff property for AE lights.
I guess the difficulty in replicating the falloff would depend upon whether or not you wanted exponential, linear (or other) falloff.
As for how to achieve that with expressions, I have no idea.
:)

* enter the expression gurus*
D***@adobeforums.com
2008-09-29 21:08:59 UTC
Permalink
Maybe this will help:

<http://www.motionscript.com/design-guide/falloff.html>

Dan
Todd Kopriva
2008-09-30 14:44:20 UTC
Permalink
Dan has already responded, so this doesn't add much. But, I wanted to point out that there's a "Simulate light falloff" <http://help.adobe.com/en_US/AfterEffects/9.0/WSAB474311-4B4C-4d54-8887-0F6459F25206a.html#WSF9E27E6B-AC71-4dd8-8135-BE2D08DA77A1> section in After Effects Help on the Web. So far, the section consists primarily of a link to Dan's website. ;-)
N***@adobeforums.com
2008-09-30 16:04:07 UTC
Permalink
Great! Thanks everyone.

I did a test plugging in the original expression into a Brightness/Contrast plug-in and changed the end number to 0,-100 and it worked just OK.

Dan's solution is much nicer looking!
S***@adobeforums.com
2008-09-30 16:15:21 UTC
Permalink
Wow Dan.
You never cease to amaze.
:)
N***@adobeforums.com
2008-09-30 16:47:56 UTC
Permalink
Hey Dan!

I'm using your expression, but I notice I have to use very very small decay amounts to get the right result. For my particular setup, I'm using a value of .0005. The expression slider I have it linked up has a range of 0 ~.001. The slider only displays to the hundredths decimal, so I get something very odd like this:

<Loading Image...>

And if I accidentally slide it into a zero or negative value, I get a divide by zero error and all my expressions turn off (which I can't undo).

Is there any way you can build in some protection against divide by zero? And multiply the decay value into something a little more user friendly?
D***@adobeforums.com
2008-09-30 20:29:24 UTC
Permalink
Sure, but you could just set your slider range to something like .01 to 1.0 and then just divide the value by 1000 when you bring it into the expression.

Dan
M***@adobeforums.com
2008-10-02 06:58:02 UTC
Permalink
Also clamp the input ranges for the slider:

clamp(0.00001,1,effect("Slider")("Slider"))

Mylenium

Loading...