Flickering Candle
|
|
Maldoror Damone
Registered User
Join date: 18 Mar 2006
Posts: 4
|
05-25-2006 06:29
Good Morning all,
I am a newbie to scripting and would like some assistance on a script idea. I would like to create a flickering light to go with some torch/candle models that I have made.
a) does it sound possible?
b) would random number generator be the best way to create the light levels? I would think it would look more strobe light than flickering as the light levels rise and fall - not jump directly to the next light level.
Thanks for your time,
Maldoror Damone bauhaus design group
|
|
Xero Havercamp
Registered User
Join date: 28 Mar 2006
Posts: 5
|
05-25-2006 07:04
I know it can be done. if you want an example of this, seek out Roc Manderblot (sp) in game. He can normally be found at TeaZers University in the lobby (he is a TeaZer instructor), but he just showed me a new flame type particle system he wrote that is probably as close to the real thing as you are going to get in Second Life.
|
|
Kaige Tokhes
Registered User
Join date: 15 Mar 2006
Posts: 11
|
hardware lighting
05-25-2006 09:01
I am going to try and add hardware light flickering also to my lights as they are all flames and i think a simple timer on off with do it although i dont know what may happen to the cpu usage as it turns on and off.
|
|
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
|
05-25-2006 11:55
I was thinking about this myself: Using the new local lighting to create a 'flicker' effect on my torches. Thing is, I can't think of a way to accomplish this without inadvertantly creating a lag machine/resource hog. I could easily use a timer(), and rapidly 'flicker' between, say, red/orange/yellow on the light glow: but wouldn't that suck for the Sim? I saw in another thread that Moopf is doing something like this, but not sure if its the obvious (timer) way, or some other innovative way that isn't so resource intensive. Inquiring minds want to know 
_____________________
------------------ The ShelterThe Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
|
|
Moopf Murray
Moopfmerising
Join date: 7 Jan 2004
Posts: 2,448
|
05-25-2006 23:19
From: Travis Lambert I saw in another thread that Moopf is doing something like this, but not sure if its the obvious (timer) way, or some other innovative way that isn't so resource intensive. Inquiring minds want to know  hehe, the little camp fire I've done uses a timer to trigger llSetPrimitiveParams to change the color of the light. A single timer isn't that resource intensive either, for what it's worth, and I doubt any other way of doing this would be any less resource intensive  In response to the original poster: a. Yup, it's do-able. b. I'm using two colors (one orange, one yellow). I'm then getting the difference between the components of each and passing that through llFrand to get a random variation between the two colors. You could also use random numbers to change the timer speed, so it's not the same time difference between each change in the light.
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
05-26-2006 03:03
It's not hugely resource intensive, although llSetPrimitiveParams gives you a 0.2s delay to the script which is worth remembering too.
It might be friendly to your customers to make the flickering optional - one or two flickering torches fine, special occasions 3 dozen also fine, but every day with 3 dozen isn't that friendly to any neighbours I suspect.
|
|
Moopf Murray
Moopfmerising
Join date: 7 Jan 2004
Posts: 2,448
|
05-26-2006 03:41
From: Eloise Pasteur It's not hugely resource intensive, although llSetPrimitiveParams gives you a 0.2s delay to the script which is worth remembering too. It might be friendly to your customers to make the flickering optional - one or two flickering torches fine, special occasions 3 dozen also fine, but every day with 3 dozen isn't that friendly to any neighbours I suspect. As with anything in SL, it's a case of "everything in moderation" 
|
|
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
|
05-26-2006 03:51
I just put a llSetPrimitiveParams([PRIM_POINT_LIGHT, on_off, <1, llFrand(1), 0>, 1.0, 10.0, 0.75]); inside a while loop, just using the inherent 0.2 sec delay.
It gave a fairly pretty flicker between red and yellow, but you could still see the transitions a _lot_, although I guess I was looking for them.
I didn't see any porformance hit, but then, it is a fairly empty sim, and it was only the one light...
Now I just need to work out how to stop / start an infinite loop from the outside *g*. Hmmm, are scripts multi-threaded? could an event trigger and change a global var while another user function was running? *goes off to play*
|
|
Moopf Murray
Moopfmerising
Join date: 7 Jan 2004
Posts: 2,448
|
05-26-2006 04:37
From: Bitzer Balderdash I just put a llSetPrimitiveParams([PRIM_POINT_LIGHT, on_off, <1, llFrand(1), 0>, 1.0, 10.0, 0.75]); inside a while loop, just using the inherent 0.2 sec delay. It gave a fairly pretty flicker between red and yellow, but you could still see the transitions a _lot_, although I guess I was looking for them. I didn't see any porformance hit, but then, it is a fairly empty sim, and it was only the one light... Now I just need to work out how to stop / start an infinite loop from the outside *g*. Hmmm, are scripts multi-threaded? could an event trigger and change a global var while another user function was running? *goes off to play* You will see the transitions, there isn't much you can do about that, unless you gradually change the light color a little each time from the starting color to the ending color. Beware infinite loops btw  You can't stop it once it's started, scripts aren't multi-threaded.
|
|
Maldoror Damone
Registered User
Join date: 18 Mar 2006
Posts: 4
|
05-26-2006 06:03
Thanks for the replies all. My god its refreshing at request help and actually get it without rudeness - one of the things that puts SL above the rest as far as community goes.
I think I will stick with just a constant light source - the majority of the lights in the Gorean section of the sim I am working on are candles and they really dont flicker that much in reality unless there is wind or its sputtering.
Thanks again for being a wall to bounce ideas off of.
Maldoror Damone
|
|
Androclese Antonelli
Org. B-Day: 05/11/04
Join date: 25 Apr 2006
Posts: 96
|
05-26-2006 06:51
From: Maldoror Damone I think I will stick with just a constant light source - the majority of the lights in the Gorean section of the sim I am working on are candles and they really dont flicker that much in reality unless there is wind or its sputtering. I have been playing with cycling between colors to give a flickering effect with my "Fire Pit's". Now, the code below is still being worked on. It needs a lot of refinement, but it might give you a starting place. I originally had the colors cycling between RED - ORANGE - YELLOW, but the color change was too much and created harsh lighting changes. I ended up going with color values that were closer to each other and, so far, the effect is nice. // Colors to cycle through list colors = [ "<1, 0.375, 0>", "<1, 0.5, 0>", "<1, 0.625, 0>" ]; // Time interval to flicker light at float flicker = 0.05; state on { state_entry() { ParticlesOn(); llSetTimerEvent(flicker); } timer() { integer random = llFloor(llFrand(llGetListLength(colors))); llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, (vector)llList2String(colors, random), 1.0, 10.0, 0.75]); } }
I hope this helps you out.
_____________________
The Sculpted Garden Originally Born 5/11/2004 - New AV, Old Player. If you leave the game, don't delete your account, just make it 'free'. You'll lose your inventory like I did. *sniff*
|
|
Kaige Tokhes
Registered User
Join date: 15 Mar 2006
Posts: 11
|
candle
05-26-2006 09:31
can i ask why the above script has particles on in it? looking for reference to it in the script or as a function and ddont see it anywhere
|
|
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
|
05-26-2006 10:08
Looking at the script, it is only a fragment of a larger whole.
If you remove the ParticlesOn() call, it will do thi lighing effect.
The particles could be used to appear as a flame, or possibly smoke, but they wouldn't be necessary to make the lighting work.
|
|
Pratyeka Muromachi
Meditating Avatar
Join date: 14 Apr 2005
Posts: 642
|
05-26-2006 13:13
From: Androclese Antonelli I have been playing with cycling between colors to give a flickering effect with my "Fire Pit's". Now, the code below is still being worked on. It needs a lot of refinement, but it might give you a starting place. I originally had the colors cycling between RED - ORANGE - YELLOW, but the color change was too much and created harsh lighting changes. I ended up going with color values that were closer to each other and, so far, the effect is nice.
I was going to ask you how you achieved that effect, because I just came back from your place and noticed the flickering effect on the ceiling and surroundings... AWSOME!!! I'll have to experiment the effect on lag, but since we are limited to see only 6 light sources max, I guess it wont affect it much.
_____________________
gone to Openlife Grid and OpenSim standalone, your very own sim on your PC, 45,000 prims, huge prims at will up to 100m, yes, run your own grid on your PC, FOR FREE!
|
|
Ben Bean
Registered User
Join date: 7 Jun 2005
Posts: 4
|
05-27-2006 04:19
During preview I was experimenting with creating such effects client-side using the TargetOmega thing. I just created a group of three invisible prims in a triangle formation (or there abouts) each with a different light colour set on it, then make that entire group spin around a center point. To make it look a little more interesting, you can put more than one of these spinning light things together at different speeds, making it appear more random.
If you play with the turn speed (which does need to be quite high) and the formation of your invisible light prims you can create some interesting effects in the right circumstances, and it's all done client-side so it won't create any lag on the server.
I was, however, doing this before the six light limitation was added in. I noticed once it was restricted that the effect didn't work so well, but that might be partially due to the large number of light prims that were around at the time.
|
|
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
|
Hmm
08-27-2006 22:26
The Script Above Gives An Error Is There A Working Version Of This Script?
|