Game Development Community

Blinking lights

by Roshan Kuriyan · in Torque Game Engine Advanced · 06/05/2006 (1:32 am) · 3 replies

Hai everybody

I am trying to include blinking lights in my mission.
i am placing a 3d sphere in my world.
i ve written material for that sphere as follows

new Material(SphereGlow)
{
mapTo = SphereTex;
baseTex[0] = "SphereTex";
emissive[0] = true;
glow[0] = true;

};

my sphere glows.
now i want to make the glow on and off continously.
i want it like a blinking light
What should i do?
could any one help me
Thanks in advance

#1
06/05/2006 (2:18 pm)
First off, do you really want to have a sphere model in you mission that adds to the polygon count? Depending on how your mission is put together, you might be better off with a player-facing billboard that fakes the light emission and uses an IFL animation to simulate a blinking light.

However, if you want to keep with the sphere model and just use shaders (your original question), the same principle applies. Replace your material definition above with something like this....

new Material(SphereGlow)
{
   mapTo = SphereTex;
   baseTex[0] = "SphereTex";
   emissive[0] = true;
   glow[0] = true;

   animFlags[0] = $sequence;
   sequenceFramePerSec[0] = 2.0;
   sequenceSegmentSize[0] = 0.5;
};

Next, replace your SphereTex image with something like this...
www.uploadfile.info/uploads/0ae3dec4a4.jpg
This will animate the SphereTex texture on the shape. In this case it's a simple 2 frame animation of red then black. The red texture will glow, but the black will not. The new shader parameter sequenceFramePerSec specifies that we show 1/2 frames per second (0.5), or rather a new frame every 2 seconds. Make the number smaller (like 0.25) to stretch the time out further for a slower blink. The sequenceSegmentSize indicates the number of frames that make up the animation something like this:

1 = 1 cell animation (1/1)
0.5 = 2 cell animation (1/2)
0.25 = 4 cell animation (1/4)

If the blinking is too harsh (like LED instant on and instant off) then add more cells into the animation with shades of red in the middle to simulate a fade to black animation. That would probably look good.

John K.
#2
06/07/2006 (10:53 pm)
Thanks a lot John
My sphere blinks with your idea.
But one half of the sphere glows and the other half is dark and this toggles continously
But is it possible to make the whole sphere glow for sometime and fully dark for the next cycle of time
and continue this action.

Roshan
#3
06/11/2006 (12:23 am)
This is really looking like a bug in TSE. Instead of showing half of the texture (all red, then all black) it appears to be showing the whole texture (half red and half black at the same time). I'm taking a look at the code in the matInstance.cpp file around the setTextureTransforms() method. I think there might be something wrong with how the texture offset is being set.

John K.