Flickering Light
Submitted by killbourne on Thu, 06/23/2011 - 22:57
Hey all
I did a little test after seeing a snippet of code posted by Mr.Admin here > http://www.gamestart3d.com/content/lights-shaders-and-candles#comment-864
I managed to get the diffuse intensity as well as the range size to flicker. Nice :)
Its not perfect. It looks more like a strobe light than a candle, but the idea is there. Hope you guys like!!
Here is the link to the vid on vimeo :) >> http://vimeo.com/25518085
and here is the code snippet used :)
function OnUpdate(item) { local light = ItemCastToLight(item); LightSetDiffuseIntensity(light, sin(Deg(g_clock) * 0.1) * 0.6 + 0.5); LightSetRange(light, sin(Deg(g_clock) * 1) * 0.6 + 0.5); }
Mr.Admin
Thu, 06/23/2011 - 23:15
Permalink
Nice!
Yes, it will be hard to make a sin function behave like a random flickering, I can propose you the following:
What this does is basically take a random number between 0.1 and 1.25 each frame and gradually ramp the current_intensity variable toward this value. You can tweak the 0.05 value to further smooth the transition and increase the intensity range (in the random call) to increase the effect.
killbourne
Fri, 06/24/2011 - 11:42
Permalink
Thanx for this.
This will make learning squirrel a lot easier as I find it much easier to learn by doing rather than looking at a bunch of explanations as to what the code means then trying to put it all together [such as with the squirrel site and docs :( ].
I suppose this is because I have no formal knowledge on coding. Smaller snippets of code that do a specific function are easier to understand thus making it easier to learn :)
I don't want to make you feel rushed, but hows the new release looking? :p Im bot eager and excited to get some of my Cinema 4D models into Gamestart.
Mr.Admin
Fri, 06/24/2011 - 13:37
Permalink
Yes, I think I need to make some really simple tutorials.
But days are short...
Anyway, I hope to release the updated version tonight ;).
François Gutherz
Fri, 06/24/2011 - 15:32
Permalink
Yaye ! A new version :)
Killbourne, I can't wait to see your Cine 4D stuff running in GameStart :D~~~