PDA

View Full Version : Skyscraper Lightrig with expressions

Limbus
05-30-2008, 02:15 AM
Hi there,
I need a little help with a (at least for me) complicated expressions setup.

I want to be able to control light intensity of a bunch of lights with a null. If the null is at y=1m all lights are at 100% intensity. If one moves the null towards y=0m one light after the other gets turned down to 0% intensity over a couple of frames with all lights at 0% when the null reaches y=0m. So the closer the null is to 0m the more lights are turned off and vice versa.

I want the y position of the null to be the % chance that a light will be at 100% intensity. So at 0.6m there 60% of the lights would be ON and 40% would be off.

Background: this would be very handy when lighting highrise buildings with lots of interior lights.

Now I don't even know where to start. Should I use expressions, relativity or Lscript expressions?

Cheers, Florian

walfridson
05-30-2008, 02:29 AM
Normal expressions will work fine.

Create your control null, I call it lightcontrol
Open the graph editor
Click on expressions tab
Name: light control
Value: ( [lightcontrol.Position.Y] )
Enter

Select all your lights in the scene editor.
In the graph, click on the "selection" button and select Get Layout selected.
Bang bunch of lights, click on the "channels" button and select filter.
Filter *.Intensity
Select all the intensity channels and click apply under the expressions tab
Now, 1 meter = 100%. If you want more or less - simply multiply your value in the expression.

Cheers

Limbus
05-30-2008, 02:45 AM
Normal expressions will work fine.

Create your control null, I call it lightcontrol
Open the graph editor
Click on expressions tab
Name: light control
Value: ( [lightcontrol.Position.Y] )
Enter

Hey Walfridson, thanks for the answer.
As far as I understand it your expression will make the light intensity = Y positon of the null. This is not quite what I was looking for ;-)
If the null is at 0.6m I would like that each light has a 60% chance to be at 100% intensity and 40% to be at 0% intensity and no value inbetween. So the light would be either on or of. At Y= 0.2 meters it would be 20% chance for on and 80% chance for off.

I hope my explanation is clear enough.

Cheers, Florian

walfridson
05-30-2008, 03:23 AM

Here's a snippet.
Ugly but should work.

edit

it's a channel lscript, so save it and add it in layout. Add to your intensity channels in graph editor under modifiers

//-----------------------------------------
// LScript Channel Filter template
//

@version 2.2
@warnings
@script channel
@name LimbusChance
// global values go here
myvalueold=0;
myint=0;
create
{
// one-time initialization takes place here
}

destroy
{
// take care of final clean-up activities here
}

process: ca, frame, time
{
// 'ca' is the Channel Filter Object Agent

// it exports one read-only data member:
// name the name of the channel as
// it is displayed to the user

// it provides two methods:
// get returns the value of the
// channel (as a floating-point
// number) for an indicated time
// index
// set sets the channel's value to
// the provided floating-point
// value for the current time
// index (indicated by the 'time'
// argument to process()).
myvalue = Mesh("lightcontrol").getWorldPosition(time).y;
if(myvalue!=myvalueold){
myrandval = random(0,100);
if(myvalue*100 > myrandval)
myint = 1; //light on 100 percent
else
myint = 0; //light off
ca.set(myint);
}
myvalueold=myvalue;

}

{
if(what == SCENEMODE) // processing an ASCII scene file
{
}
}

save: what,io
{
if(what == SCENEMODE)
{
}
}

options
{
reqbegin("<Requester Title>");

c0 = ctlinteger("Integer Control",1);
c1 = ctlnumber("Number Control",1.0);
c2 = ctlstring("String Control","my string");
c3 = ctlcheckbox("Checkbox Control",true);
c4 = ctlpopup("Popup control",1,@"Item 1","Item 2","Item 3"@);
c5 = ctlchoice("Choice Control",1,@"X","Y","Z"@);

return if !reqpost();

// get requester control values here

reqend();
}

vfxwizard
05-30-2008, 03:33 AM
If the null is at 0.6m I would like that each light has a 60% chance to be at 100% intensity and 40% to be at 0% intensity and no value inbetween.

If this is what you need (no smooth change between on and off), then it's easier. The light's intensity Relativity expression is:

COND( YW(lc,t) > (#ex/25) , 1 , 0 )

Which takes the clone number (#ex) and divides it by the maximum number of lights used, 25 in my case. According to Y coordinate of the controller null the CONDitional turns the light on -1- or off -0-.

The attached test scenes use luxigons in a regular grid, so lights will grow in lines and columns, you have to adapt the light positions (or the unwelded luxigon positions) in a more random distribution.

Render the "duplicated" anim to get a feeling for what I mean with regular grid, and let me know if I can clarify further how it works.

Limbus
05-30-2008, 03:39 AM
Wow! Thanks guys for the very fast response. I will try both solutions and report back.

Florian

Limbus
05-30-2008, 04:16 AM
it's a channel lscript, so save it and add it in layout. Add to your intensity channels in graph editor under modifiers

This does work in OpenGL but when I render it all lights at 100%. Even the OpenGL shows all lights at 100% after the render until I move the timeline again.
And as far as I understand the code the LS assigns new values at every frame. I think this will cause a light to be turned on and off frequently which will lead to light flickering in animations. It would be cool if a light is kept at 0% once it reaches 0% the first time.

The attached test scenes use luxigons in a regular grid, so lights will grow in lines and columns, you have to adapt the light positions (or the unwelded luxigon positions) in a more random distribution.

This works nicely. Would it be possible to randomize the light that get turned off so one would not have to rearrange the lights by hand to get a more random effect?

Thanks for all the help so far!

Cheers, Florian

walfridson
05-30-2008, 05:15 AM
This does work in OpenGL but when I render it all lights at 100%. Even the OpenGL shows all lights at 100% after the render until I move the timeline again.
And as far as I understand the code the LS assigns new values at every frame. I think this will cause a light to be turned on and off frequently which will lead to light flickering in animations. It would be cool if a light is kept at 0% once it reaches 0% the first time.

No, it saves the last controllight Y value, if it differs(you animate it) a new randomized value will be checked*.

* Will try it myself later :)

vfxwizard
05-30-2008, 05:22 AM
Would it be possible to randomize the light that get turned off so one would not have to rearrange the lights by hand to get a more random effect?

Unfortunatly as soon as you begin using random numbers it becomes hard to keep the number of lights turned on proportional to the controller null.

It would be necessary to map each clone number to another clone number, without repetitions. With scripting it's easy, just an array, but not with expressions.

How do you place lights? If you use luxigons it's very easy to scramble the lights. See the newly attached scenes, I just cut some polys at random (using Select Nth) placing them in other layers then recopied an repasted all in a single layer. This way the sequential clone numbers will reference randomly distributed lights.

If you can't use luxigons please explain how you arrange lights (cloning, by hand, are located with a specific pattern etc...), maybe a solution can be found.

Limbus
05-30-2008, 07:30 AM
Unfortunatly as soon as you begin using random numbers it becomes hard to keep the number of lights turned on proportional to the controller null.

How do you place lights? If you use luxigons it's very easy to scramble the lights.

Luxigons should work fine for me most of the time. Thnaks for the help. :thumbsup:

Florian

Limbus
05-30-2008, 09:02 AM
No, it saves the last controllight Y value, if it differs(you animate it) a new randomized value will be checked*.

Good. it just looked like this in OpenGL but then the OpenGL preview is not very accurate.

Cheers, Florian

Limbus
06-05-2008, 02:46 AM
* Will try it myself later :)

Did you get a chance yet to try it out?

Cheers, Florian

Matt
06-05-2008, 03:07 AM
This isn't what you've asked for, but it may be useful in some way:

Free Script : Auto (Unique) Surface Rename

http://www.newtek.com/forums/attachment.php?attachmentid=13490&d=1090937732

Limbus
06-05-2008, 03:11 AM
This isn't what you've asked for, but it may be useful in some way:

Free Script : Auto (Unique) Surface Rename

Thanks, this could be quite usefull if I use lumi-polys instead of lights.

Cheers, Florian