PDA

View Full Version : Accessing channels in expressions



xxiii
04-04-2012, 05:39 PM
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.

dwburman
04-04-2012, 10:10 PM
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.

RebelHill
04-05-2012, 12:21 AM
[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.

xxiii
04-05-2012, 02:36 AM
[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.

RebelHill
04-05-2012, 04:22 AM
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.

xxiii
04-05-2012, 11:59 AM
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?


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).

RebelHill
04-05-2012, 01:05 PM
self appears as...

Value (no brackets, etc)

which is whatever the current keyframe value is.

dwburman
04-05-2012, 02:23 PM
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. :)

xxiii
04-05-2012, 04:14 PM
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.)

xxiii
04-05-2012, 04:41 PM
...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.

dwburman
04-05-2012, 07:37 PM
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. :)

RebelHill
04-06-2012, 01:12 AM
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.

xxiii
04-06-2012, 11:25 AM
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.

RebelHill
04-06-2012, 01:10 PM
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.

xxiii
04-06-2012, 05:27 PM
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 (http://en.wikipedia.org/wiki/Inverse-square_law#Light_and_other_electromagnetic_radiati on)

dwburman
04-07-2012, 12:25 AM
Are you trying to replicate the way light travels in the real world, (inverse-square law)? Isn't that what LW's Intensity Falloff: Inverse Distance ^2 does?

RebelHill
04-07-2012, 05:28 AM
Yes...

U dont need any kind of squaring in your expression at all... thats what the falloff type is for.

And I guess... why not let LW have access to parameters that can be enveloped irrespective of if one has been created or not... but atm at least, LW doesnt work that way. The envelopes dont actually EXIST unless you've created them. No reason LW couldnt just create all possible such channels by default, but maybe there's also good reasons not to. Wouldnt know one way or the other really.

xxiii
04-07-2012, 11:50 AM
What I was trying to get was a particular intensity at distance D from the light, when the light is an inverse-squared (real-world physics) light.

Before it was pointed out that I could just set range to D, I was calculating the math "backwards" (which does require squaring) to figure out what intensity to set the light to to result in that particular intensity at that particular distance.

However, I can just set range to D, which solves this particular problem (and makes lightwave do the same calculation internally that I was trying to do).