Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Light falloff and parented objects

  • Light falloff and parented objects

    Posted by Seth Parker on March 5, 2009 at 1:58 am
    decay = .005;
    noFalloff = 200;
    
    L = thisComp.layer("Light 1");
    d = length(L.transform.position,transform.position);
    if (d < noFalloff){
      value;
    }else{
      value/Math.exp((d - noFalloff)*decay);
    }
    
    
    

    This may have been answered before, but my best googling and searching revealed nothing, so I thought I'd ask here. I've been using Dan Ebbert's light falloff expression, but the object I'm lighting is a series of clips rotating around the origin of the 3D space. I've got all the clips parented to a null object that rotates, thus creating the rotation around the fixed point. Anyway, the expression I have is based on the objects location info, but since all the objects are parented to the null, the info doesn't update and thusly neither does the lighting. Has anyone got any suggestions or workarounds for this problem?

    Seth Parker replied 17 years, 2 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    March 5, 2009 at 2:10 pm

    Try it this way:

    decay = .005;
    noFalloff = 200;

    L = thisComp.layer(“Light 1”);
    d = length(L.transform.position,toWorld(anchorPoint));
    if (d < noFalloff){ value; }else{ value/Math.exp((d - noFalloff)*decay); } Dan

  • Seth Parker

    March 6, 2009 at 7:23 am

    Unfortunately this didn’t work either. Since my null object is stationary except for rotation, I think the script still doesn’t detect any change. That is if I’m interpreting the additions to the code correctly.

    Do parented objects not have any data that changes if their parent changes position?

    Or is there a way to use the parent’s data to generate what the parented objects actual location would be? Sort of like a difference equation?

    I thank you for your help with this. I’m really just getting into expressions, so I have no true understanding of the language’s parameters.

  • Dan Ebberts

    March 6, 2009 at 11:39 pm

    I just tried it, and it works for me. Hard to say what’s going on without seeing your setup.

    Dan

  • Seth Parker

    March 7, 2009 at 6:48 am

    I think this will make it clearer. I followed this tutorial to create a ring of layers around a null object:

    https://library.creativecow.net/articles/dewaele_tielman/simple_ring.php

    I then just keyframed the null to just y-rotate 360 degrees. No x,y,z position change at all. So I think the script isn’t changing anything with the lighting because the position variables of the layers I’m trying to affect aren’t changing. When I scroll through the timeline, the position of the layer and the anchor point of the layer all stay the same. Does that make sense?

    I’ve been working with a friend who knows math really well, and we’re trying to generate a formula that simulates the x,y,z position of the layer by using the y-rotation value of the null object at any given point in time. He thinks we can do it with some sort of sine function, so we’ll see how that turns out. I’ll let you know if I make any headway.

  • Dan Ebberts

    March 7, 2009 at 5:37 pm

    I think you may be re-inventing the wheel. That’s what toWorld() does. It gives you the position in world space even though the Position and Anchor Point values of a parented layer don’t change.

    Dan

  • Seth Parker

    March 9, 2009 at 12:55 am

    Well that shows how much I know about AE Expressions. I probably should’ve looked that up. 🙂

    I messed with it again and figured out what I was doing wrong. I was assuming that when the layer got closer to the light, it would just automatically get brighter. Well it would have if it hadn’t been beyond the falloff distance. I adjusted the numbers a little and it works just fine. Thanks for your help!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy