Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Accessing channels in expressions

  1. #1
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793

    Accessing channels in expressions

    I am trying to access the range property of a light in an expression. I don't understand what I am doing wrong, given a light named Light, I have tried:

    [Light.Range] which results in "Invalid channel reference"

    Light.Range which results in "Too few results generated"

    Light.Range(Time) which results in "Too few results generated"

    Light.wpos(Time) which results in "Expression OK", except I don't want wpos, I want range. how do I get the Range value (or any other channel)?

    And just for fun to see if there is a difference between range and something which really doesn't exist: Light.asdfgalvb -> "Too few results generated".

    The graph editor displays this as "Light.Range" so I naturally assumed that was how one would access the channel (in conjuction with reading the lscript and layout documention PDFs), which (paraphrasing) says "You can access any channel in the entire system by doing [thingie.channelname]" but apparently not. What ridiculously obvious thing am I overlooking?

    I'm also not sure if case is important (from the examples, I'm guessing not), but I've tried variations Range, range, RANGE, with no success.
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  2. #2
    Super Member dwburman's Avatar
    Join Date
    Feb 2003
    Location
    Washington State, USA
    Posts
    2,880
    You can right click on a channel in the graph editor and select "Append to expression". I'd try that and see what it gives you.

    [Edit] I tested it and it returned [Light.Range]. My guess is that [Light.Range] is the correct syntax, and that case is important, but my knowledge of expressions is very shallow. I did try Light.Range and was getting some of the same errors you were getting, but at some point things started working. The last time I tried [Light.Range], the Validate button was greyed out but the Apply button worked.
    Last edited by dwburman; 04-04-2012 at 10:28 PM.
    [mr] Dana W. Burman | http://dwburman.com
    Motion Graphics for sale at Pond5 Stock Footage
    Check out my tutorials at Liberty3d.com & my YouTube channel!

  3. #3
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,771
    [Item.Channel] is ofc correct, so if the channel appears in graph editor as [Light.Range] then that is def it, but you can ONLY reference channels that exist within the scene... This is where u can sometimes get the disconnect, as certain channels only come into existence once an envelope is created for them. So if you've popped up a scene and NOT clciked the E next to the range parameter to create the channel, then it wont be available as a reference.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  4. #4
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    Quote Originally Posted by RebelHill View Post
    [Item.Channel] is ofc correct, so if the channel appears in graph editor as [Light.Range] then that is def it, but you can ONLY reference channels that exist within the scene... This is where u can sometimes get the disconnect, as certain channels only come into existence once an envelope is created for them. So if you've popped up a scene and NOT clciked the E next to the range parameter to create the channel, then it wont be available as a reference.
    I was experimenting with this, and within the Modifiers tab (which is where I'm trying to do this) it appears you can't reference channels at all. Within the expressions tab it seems to be as you said above. So is there any way to get the value without attaching an envelope to it? (which in this case would effectively defeat the purpose).

    I'm trying to set the light intensity based on its distance to another object, and would prefer to not make the assumption that range/nominal distance is always going to be 1 meter. (I'd like to take the intensity falloff setting into account as well, but am currently assuming its inverse squared).

    Here is the formula I have:

    pow((vmag( abs( Key_FP.wpos(Time)- Key.wpos(Time))))- 1.0, 2)

    Which I would like to turn into:

    pow((vmag( abs( Key_FP.wpos(Time)- Key.wpos(Time))))- [Key.Range], 2)

    (or whatever the correct syntax would be to access the range property of the light, preferably without knowing whether it was enveloped or not). I would like to think that all properties of all entities would be accessible, but apparently this isn't the case? (at least for expressions)

    Perhaps it isn't going to be possible. Or maybe I can do it if I attach a "python" modifier (as opposed to "expression"), but this appears to require an external file, which I'd prefer not to have; is there a scene-specific place for python scripts of this sort? (I don't see anything in the paths options.)

    I suppose I could add an envelope to range after all, at least to indicate that the value shouldn't be touched (but i'd prefer not to). And I'd like to add a slider to set the light intensity to values other than 100%. Basically, the idea is to get a physically accurate light, that is 100% (or other value) bright at the target point. Physically accurate meaning that the light obeys the inverse-squared law.

    p.s. It seems to be a bit picky about spaces also, at least with respect to the minus sign.
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  5. #5
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,771
    no... non motion envelopes ONLY exist in layout once created... which is done by clicking the E. You're not ATTACHING an envelope for the given parameter... you're CREATING one for it. Also, yes, the expression modifier doesnt have access to as many things as the graph editor version. Just doesnt.
    Last edited by RebelHill; 04-05-2012 at 04:25 AM.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  6. #6
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    So even though the light has a range property, there is no way to get at it without having an envelope for it. Can I get at it with python?

    Quote Originally Posted by RebelHill View Post
    Also, yes, the expression modifier doesnt have access to as many things as the graph editor version. Just doesnt.
    I guess I'm slightly confused by this as they both appear within the graph editor, and I'm not quite sure what the difference is, other than I gather the (non-modifier version) of an expression can be named and drive more than one thing. (I was also wondering if there is a "this" or "self" variable when its being used this way).
    Last edited by xxiii; 04-05-2012 at 12:04 PM.
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  7. #7
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,771
    self appears as...

    Value (no brackets, etc)

    which is whatever the current keyframe value is.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  8. #8
    Super Member dwburman's Avatar
    Join Date
    Feb 2003
    Location
    Washington State, USA
    Posts
    2,880
    It sounds like you might need to put the expression on the Light.Range channel and tie it to a distance between your light an another object. The range setting of the light is there to tell the light what it's range is when falloff is on. It's not a range finder. In other words, Light.Range isn't a source, it's a destination. You can read it's values, but only if you tell it what those values should be. If you want the distance between the light and an object, you need to look at the difference between their positions.

    You could use expressions to drive both the light intensity and falloff (range) using another channel or distance to a null or something.

    Of course, I could be misinterpreting what you want to do.
    Last edited by dwburman; 04-05-2012 at 02:27 PM.
    [mr] Dana W. Burman | http://dwburman.com
    Motion Graphics for sale at Pond5 Stock Footage
    Check out my tutorials at Liberty3d.com & my YouTube channel!

  9. #9
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    Quote Originally Posted by RebelHill View Post
    self appears as...

    Value (no brackets, etc)

    which is whatever the current keyframe value is.
    Does this just refer to the specific value of the channel though, or the item?

    lets say I have the same expression attached to three different things, and I want the wpos for whichever thing is currently being evaluated. Can I do Value.wpos(Time)? (which would translate respectively into item1.wpos(time), item2.wpos(time), and item3.wpos(time) as the 3 items are evaluated.)
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  10. #10
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    Quote Originally Posted by dwburman View Post
    ...You could use expressions to drive both the light intensity and falloff (range) using another channel or distance to a null or something.

    Of course, I could be misinterpreting what you want to do.
    I currently have the light, and a null. I position the null at the point where I want the light to have 100% illumination. I measure the distance between the light (minus range) and this null, and set the light to the square of this distance. This should result in a "correct" exposure at that point. Currently I'm assuming range is 1 (as it most likely will be), but I'd prefer the formula to be able to take into account whatever it happens to be set to (I'm not a big fan of assumptions, even ones which are very likely).

    So, for a white object 6 meters from the light to result in a value of 1.0 (or 255,255,255 in 8 bit) in the rendered image, with a range of 1, the light intensity needs to be set to 2500% (so at 1 meter from the light, the intensity will be 2500% + 5 meters to the object, with inverse squared results in 100% at the object).

    In the real world, I'd be playing with some combination of ISO/f-stop/shutter-time, but since Lightwave doesn't simulate that (in an exposure value sense), I'm modifying the light source intensities instead.
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  11. #11
    Super Member dwburman's Avatar
    Join Date
    Feb 2003
    Location
    Washington State, USA
    Posts
    2,880
    Okay, so you want to add the light range setting into your calculation?

    At any rate, I'm a bit out of my depth here, so I'll just wish you well in your quest and be on my way.
    [mr] Dana W. Burman | http://dwburman.com
    Motion Graphics for sale at Pond5 Stock Footage
    Check out my tutorials at Liberty3d.com & my YouTube channel!

  12. #12
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,771
    Ok... so ur trying to use an expression to set the range parameter for the falloff.

    In taht case you dont need any of this Light.Range stuff.... why would you... Light.Range is the value your EFFECTING... you're NOT trying to read it. Nor do you need to do any kind of squaring or anything else of that nature in your expression.

    All you want is to envelope the range channel, and give it a "vmag (light<->null)" Making the lights range parameter be whatever the distance between the light and null is, and set the light intensity to 100.

    Done.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  13. #13
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    Quote Originally Posted by RebelHill View Post
    Ok... so ur trying to use an expression to set the range parameter for the falloff.
    No, I'm not. Though what you said I suppose would be an alternate approach, and probably a better one, assuming its equivalent (I'm trying to think now what pitfalls or hidden variables there might be. I suppose this is why the range parameter is adjustable and I'm kicking myself for not realising it).

    (I still think expressions should have access to all parameters though).

    All you want is to envelope the range channel, and give it a "vmag (light<->null)" Making the lights range parameter be whatever the distance between the light and null is, and set the light intensity to 100.

    Done.
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

  14. #14
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,771
    range on a falloff light is the distance at which geo will receive the illumination amount dictated by the lights intensity, falloff type being how "steep" the brightness either side of this point is. So doing it that way is the most efficient.

    And expressions do have access to all envelopable parameters, the only restriction being that a channel cannot reference itself, as that would create a loop, save via the "Value" variable, which essentially is the keyed value, and therefore external the the expression result.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  15. #15
    Unsqueezable Sponge xxiii's Avatar
    Join Date
    Nov 2007
    Location
    Ogden, UT
    Posts
    793
    Quote Originally Posted by RebelHill View Post
    And expressions do have access to all envelopable parameters, the only restriction being that a channel cannot reference itself
    And that there be an envelope. let me amend my statement to be: I still think expressions should have access to all parameters, whether or not there happens to be an envelope associated with it.

    P.S. For reference: inverse-square law
    <*> -- Know Future

    Zap: Magnify that death sphere. ... Why is it still blurry?
    Kif: That's all the resolution we have. Making it bigger doesn't make it clearer.
    Zap: It does on CSI: Miami.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •