Tag Archives: Shader

Hey, I'm Simon and I'm making a game!! :)
Support me: Wishlist & Play Demo on Steam

A light has two states: ON and OFF. To define a blinking light you have to define a time it shall be on and a time it shall be off. But in Sacred 2 we had the additional parameter “delay”. I’ll explain it later. First, watch how the shader looked in the game.

Source: Sacred 2

What you see here, is our pulse shader. The color the glowing part was set in the diffuse texture. The intensity was defined in the specular alpha. But this shader used an additional RGB “pulse” texture:

Source: Sacred 2

This is the texture of the asset you saw above. Below the big version (RGB) you can see the separate channels. And every one has a special meaning:

R: Delay
G: Length ON
B: Length OFF

You need a basic time constant, let’s say: 1s. This is your maximum duration a pixel can be on/off. A color value of 255 would mean: 1 second duration.

To make a blinking light, you don’t need the delay value (R channel). You could make the green & blue channel white (on/off length would be equal) and it would look like this:
If you use a very dark G channel (Length ON) but a very bright B channel (Length OFF) it looks like this:

“But Uncle Simon…why do you waste a channel for this delay thingie, when you only need two channels to do the blinking?”

You need this delay parameter for doing these “moving” light animation you saw in the first picture. Because, every light strip shall be on/off for the same time but at a different time.

An nice note about Sacred: you can extract the zip files in the \pak\ folder to get all the DDS files. Also you can read every shader because the uncompiled versions lay in the shader directory.