| Your setup should look like this: | |
|
Now we have to map the distance to the lights brightness. To get an idea of the range of values we are talking about create a Result node and connect it to the distance nodes output port. Switch on Animation Refesh in the Xpresso->Calculate menu to get a live update of the result value. Moving the sphere along it's z-axis you can test the setup. If you don't change the X and Y positon of the sphere the smallest distance should be somewhere just below 140 units, so this is our minimum distance which shall result in maximum brightness. Now move the sphere away along the z-axis until you reach the next light. The distance should be somewhere around 330 units which will be the distance where the light will have it's lowest brightness. Since we don't want the light to become totaly dark we will use a range of brightness between 20% and 100% (0.2 - 1.0). To convert the range (Info) of 330/140 to 20%/100% you can use a number of math nodes or the range mapper node. We will use the range mapper since it was created for exactly this purpose. Replace the Result node by the Range Mapper. We will need a second light object node to control the brightness. Just drag it from the object Manager and place it to the right of the Range Mapper. You can create the connection by starting a wire from the Range Mapper output port and dragging it on the blue rectangle in the top left corner of the light node. |
![]() |
| Set the output range of the Range Mapper to Percent and enable Clamp Lower(Info) as well as Clamp Upper. Since our ranges are inverted (High value will be mapped to low value) enable the Reverse option. We will not use the Spline option in this example so deactivate it. Enter the ranges in the parameter fields. | ![]() |
| To copy this setup to the other lights we will have to make some changes first. What we need is to change the reference of the lights object node. Currently it's set to light1 and copying the Xpresso tag to other lights won't change this. The solution here is to use the Relative reference. Select both light nodes and change the reference type from absolute to relative. From now on these object nodes will referenc to the object that has the Xpresso tag, regardless the type of object. If you copy the tag to an object that does not have the ports you are using they will be set to undefined. I.e. there is no Brightness value on a cube object. Now we can safely create copies of the Xpresso tag for all the other lights by using Ctrl+drag on the tags. (scene) (animation) |
![]() |
| The setup we created has some drawbacks. If you want to change the distance or brightness range you will have to do this seperately for every Xpresso tag or you have to replace the tags by a changed one. A first step to make this easier is to allow access to the needed values from outside Xpresso by one of the methods shown here. This will enable you to multi select the lights (when using User Data) or the tags (XGroup Ports) and change all values simultanously. However you are still stuck with one Xpresso tag for every light. (scene) To avoid this we will use an iterator to repeat the same operation on every light. In this case two iterators are usable. The Hierarchy and the Object List iterator. Hierarchy enables you to iterate to all children of our Null called lights, which might pose a problem if you use a more complex hierarchy for your lighting setup. In this case the better choice is the Object List iterator which will iterate through all objects you put in the list. Delete all Xpresso tags except for the one on Light1, then create an object List iterator node. Since we will use the setup on the Null please set the reference of the Light object nodes to absolute, otherwise they will change to the Null which doe snot have a brightness value. Now move the tag from Light1 to the Null named Lights. |
|
Now we connect the Instance output port of the Object List iterator to the object input ports of the two light object nodes. This way the reference will be changed to all objects in the object list in succsession. To make the setup easier to use let's make all the values that might need tweaking available as properties of the Xpresso tag. (Info). Also you can change the order of ports by dragging the port name. This makes it easier to keep our setup clean. (scene) |
|
|