Not sure if “Scripting” is the right place for my question or if would be better placed into the “Graphics” forum.
I want to have blinking lights on a space ship hull. Just like the position lights that airplanes have. Real lights would have too much of a performance impact and this doesn’t really have to affect lighting in any way, so a cheaper approach would be nice. I know that there is a way by creating a shader that makes such lights blink using the time delta and a sin function on a color channel (mostly alpha channel) of a texture… i think it was a shader for pusalting shields or sth… that can surely be abused for my purpose i hope… I simply can not remember how this was done and I can’t find anything here on the forums
(probably i’m searching for the wrong terms)
The programming is not the problem but could anyone give me a hint that might enlighten me?
Materials have an “emit” feature, you could change that via scripting, and mybe you coukd change the darkness of it too, it can give out a nice effect, and it’s performance friendly too.
1 Like
Not sure about performance but I would use flashing halos, you get a nice glow to the lights as you would in clouds etc 
I second gorbit99’s technique. Copy your ship’s texture and make it black everywhere except your lights (which are white). In the Standard material you set the Emission texture to the black/white image and you can change it’s brightness dynamically. I forget which values you have to change in the material (you might search around), but I think you can change the glow color with “_EmissionColor” and toggle it between black and white to get the blink.
1 Like
Thanks a lot for your answers, and yes - scripting is a good option. This morning I maybe found the other method I was intending to use. Based on those shield shaders from http://wiki.unity3d.com/index.php?title=Shield that use a time-based sine-value to modify the alpha-channel of a texture i might be able to reach my goal.
Pseudo code:
float t = abs(_SinTime); // values from 0 to +1
float a = int(texture.Alpha / 255); // casting alpha/255 to an int results in values for 0 for anything <255 and 1 for alpha=255
o.Alpha = a * int(t); // reducing t to being either 0 or 1;
That way I might be able to create a shader-only solution without the need to script anything. As I’m currently working on a voxel-based game I don’t want every single voxel to be scripted.
what if this blinking light is within an asset bundle? I can make an emission blink via script fine in Unity, but one it is bundled and inserted into the game, it no longer works or gives very unwanted results.