Sat, Jan 18, 10:58 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Randon Light script


nyguy ( ) posted Thu, 28 February 2008 at 4:17 PM · edited Sat, 18 January 2025 at 10:57 PM

I am setting up a scene in poser and I want the lights to randomly turn on and off for the 600+ frames. I would also like to change the colors How would I do this using a python script or is there one already that would do this. I am looking at about 10 lights in the scene but can do as low as 5 to get the effect I want.

Poserverse The New Home for NYGUY's Freebies


bagginsbill ( ) posted Fri, 29 February 2008 at 1:45 PM

file_400972.jpg

I'm sure someone will come along with a script, but here's another way to do it.

Did you know that lights have shaders? Yep they do.

And did you know that a shader can consult the Frame Number in an animation? Yep.

And did you know that you can use the Frame_Number to drive a Fractal_Sum (a kind of noise) node?

So here is a light shader that changes randomly, on or off. Of course the color can be anything you want.

Here's how to adjust it.

The Math_Functions node (the "Step") in the upper right controls the probability that the light will be on. Value_2 controls this. With a value of .5, it means on average the light will be on 50% of the time.

The Fractal_Sum node is generating the random sequence. To make more frequent changes, lower the X scale and Y scale values. To make less frequent changes, increase the X scale and Y scale. With the current settings (1) it changes about 3 to 7 times in 30 frames.

The Math_Functions_2 node is so you can make sure your lights are not synchronized. It causes the Fractal_Sum to move to a different plane in its internal 3D space. I'm showing my Light 2 here with a value of 50. For each light, add another 50. So for Light 3 use 100. For Light 4 use 150. Etc.

Be aware that the preview in the pose window does not show this going on. But the preview in the material room does. So you can select a frame with the frame slider and see if that light is on or off at that moment. Because Poser ignores the Light Intensity nodes in preview, if you're doing animation using the preview renderer, forget I said anything.

This light starts off, turns on at frame 8, off at 11, on at 17, off at 21 on at 23, off at 28, on at 30. That's as far as I checked it. With other values instead of 50, it will produce a different pattern.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


nyguy ( ) posted Fri, 29 February 2008 at 1:59 PM

Thanks I have this book marked and will try this once I get the time this evening.

Poserverse The New Home for NYGUY's Freebies


nyguy ( ) posted Fri, 29 February 2008 at 7:31 PM

Could not get this to work.

Poserverse The New Home for NYGUY's Freebies


markschum ( ) posted Fri, 29 February 2008 at 10:09 PM

Thats extremely good !!!


markschum ( ) posted Fri, 29 February 2008 at 11:04 PM

I had a look and the script isnt that difficult .

The problem is that the light on/off is not animatable (?) so it would have to be an intensity change and set in adjacent pairs of keyframes so the change is abrupt.

I should have that done soon though .


markschum ( ) posted Sat, 01 March 2008 at 12:20 AM

file_400990.txt

ok, I have a script that may work for you .

stupid Poser and Python made it harder :(    but thats to be expected :-)

The script stores the intensity of all lights at frame 0 so the scene can be lit as desired.
it steps through each 30 frames and adds a random number between 1 and 9 for each light so they dont all change on the same frame , and randomly turns them on or off by setting the intensity.
A constant interpolation is used for the intensity parameter so the slines dont mess it up and double keyframes can be avoided.

The frame count and random frame can be altered - read the comments in the script.

script attached, rename as randomlights.py  or whatever name you like


nyguy ( ) posted Sat, 01 March 2008 at 12:42 PM · edited Sat, 01 March 2008 at 12:47 PM

Thanks! This will work  perfectly :thumbupboth:

What would I have to change to get The lights to change faster?

Poserverse The New Home for NYGUY's Freebies


markschum ( ) posted Sat, 01 March 2008 at 2:16 PM

 
fs = 30     # frame step value
fr = 10     # random frames added to step position

the frame step value sets up every 30 frames (1 second)
the fr value adds from 1 to 9 frames to that number so a light may change at 34,68,92 frames for example

if you set fr lower than 10 but at least 2 the lights will change closer to each other
if you set fs lower but at least 1 , there will be more changes during the anim.
setting fs = 1 and fr =2 will cause a change almost every frame

I would not try lower that fs = 5 and fr = 2  and then increase

The way this uses randoms there will be times the light does not change. Its like flipping a coin, sometimes you will get three heads in a row . 


nyguy ( ) posted Sat, 01 March 2008 at 6:22 PM

Here is a test of what I have done.

Poserverse The New Home for NYGUY's Freebies


nyguy ( ) posted Sat, 01 March 2008 at 8:41 PM · edited Sat, 01 March 2008 at 8:42 PM

Here is another one on my You Tube page. This  one is with an edited version of your script. 

THANKS AGAIN!

Poserverse The New Home for NYGUY's Freebies


nyguy ( ) posted Fri, 21 March 2008 at 9:07 AM

Markschum, thanks for this python script it has been great help! Do you mind if I post this on my website as freebie? You will get all credit.

Poserverse The New Home for NYGUY's Freebies


markschum ( ) posted Fri, 21 March 2008 at 10:22 AM

thats ok , so long as its a freebie :-)


nyguy ( ) posted Fri, 21 March 2008 at 10:59 AM

I will get the original uploaded tonight. I have also been fiddling with the script a little to see about changing the speed and rate.

Poserverse The New Home for NYGUY's Freebies


nyguy ( ) posted Sat, 22 March 2008 at 10:10 AM

Okay this has been added to my site. I did make a few modification.

I gave you credit along with PhilC who helped me modify it some. What I added was a way to let the user input the numbers they want to use. Also created a tutorial for it.

Poserverse The New Home for NYGUY's Freebies


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.