Page 1 of 1

Pulsating Color

Posted: Sat Jan 31, 2004 7:05 am
by diego
I have a custom texture that I have set up to pulsate in the shader. Everything is working fine. I was just wondering if it was possible to change the pulsating color to something besides red.

color

Posted: Sat Jan 31, 2004 8:00 am
by tltrude
I think this is what you want. Normalized means the three color numbers are between 0 and 1. They probably go where it says <base>.

6.3.3 rgbGen wave <func> <base> <amp> <phase> <freq>
Colors are generated using the specified waveform. An affected texture with become darker and lighter, but will not change hue. Hue stays constant. Note that the rgb values for color will not go below 0 (black) or above 1 (white). Valid waveforms are sin, triangle, square, sawtooth and inversesawtooth.

<func> Wave forms and their effects:

Sin: color flows smoothly through changes.
Triangle: color changes at a constant rate and spends no appreciable time at peaks and valleys.
Square: color alternates instantly between its peak and valley values.
Sawtooth: With a positive frequency value, the color changes at a constant rate to the peak then instantly drops to its valley value.
Inversesawtooth: An inverse sawtooth wave will reverse this, making the ascent immediate (like a square wave) and the decay fall off like a triangle wave.

<base> Baseline value. The initial RGB formula of a color (normalilzed.
<amp> Amplitude. This is the degree of change from the baseline value. In some cases you will want values outside the 0.0 to 1.0 range, but it will induce clamping (holding at the maximum or minimum value for a time period) instead of continuous change.
<phase> See the explanation for phase under the waveforms heading of Key Concepts.
<freq> Frequency. This is a value (NOT normalized) that indicates peaks per second.

Posted: Sat Jan 31, 2004 12:05 pm
by diego
I just noticed this tidbit in the shader that I copied:


{ // pulsating layer
map textures/models/items/pulse.tga
blendFunc GL_SRC_ALPHA GL_ONE // An additive blend that uses alpha
rgbGen wave sin 0.25 0.25 0 0.75
alphaGen distFade 1024 512 // this makes the pulsating fade when you go away from it
}

The color is determined by the color of the pulse texture. I changed that one to a bright green and it worked great. But all that info you provided me about the pulse frequency and waveform will come in handy.

The original pulse texture is extremely tiny. Only about 4 pixels. But I don't see any reason why I couldn't use a larger texture with a colored emblem like the swastika surrounded on a field of black. I haven't tried it yet, but in theory, that would give me a glowing pattern overlay. The black areas would remain the same. Placement of that texture would be problematic. So I would probably have to make the color overlay the same resolution as the base texture. I'll have to experiment with it some more.

color

Posted: Sat Jan 31, 2004 3:58 pm
by tltrude
That number after "sin" is the base color--looks to be kinda blueish. If you made it (.25 .75 .25), it might make it even greener. To apply it, why not make it a decal and use the texture on a patch mesh. Here is an example of a decal shader.

Code: Select all

1
{
	qer_editorimage textures/decals/1.tga
	polygonOffset
	cull none
	{
		map textures/decals/1.tga
		blendfunc blend
		alphagen vertex
		rgbgen vertex
	}
}
The patch mesh should overlap the wall brush face.

Re: color

Posted: Sun Feb 01, 2004 2:54 am
by diego
[quote="tltrude"]That number after "sin" is the base color--looks to be kinda blueish.

Actually, I think the base does not refer to color, but probably the lowest intensity of the additive pulse. The default .25 probably keeps the red glow from going completely transparent.

There are actually 4 numbers in that stock shader after the "sin" function:
.25 ..... .25 ...... 0 ..... .75

If these were representative of RGBA values, that would not be a bluish hue. I think they accurately correspong to values for Amplitutde, phase and Frequency that you described earlier. When I made adjustments to these values, I Did notice a difference in the rate of pulse, but not the color.


I am not familiar at all with the use of decals. I assume it has something to do with the bullet holes on surfaces or scorches from grenades. So I am really not sure what this would do for me. Would that make pulsating bullet holes when I shoot the walls? That would look kind of cool.

Posted: Sun Feb 01, 2004 2:29 pm
by tltrude
Diego wrote:Placement of that texture would be problematic. So I would probably have to make the color overlay the same resolution as the base texture. I'll have to experiment with it some more.
Decals are more than bulletholes and blastmarks. The "polygonOffset" line in the shader is the key line. It lifts the texture a hair off the surface of the patch mesh. So, if your pulsating emblem were applied to a patch, you could stick it on any surface you wish. If you want to try it, just add that "polygonOffset" line to your shader.

I'm not sure if these two line are needed or not, but they are in most of the decal shders.

alphagen vertex
rgbgen vertex

Posted: Mon Feb 02, 2004 7:24 am
by diego
I'm confused about the decal. Are you saying it is only applied to patch meshes? Or can it be on any brush?

brush

Posted: Mon Feb 02, 2004 8:52 am
by tltrude
I guess you could put it on a brush with nodraw on the other 5 faces. But, the face the decal is on has to overlap the brush face you want it applied to. In other words, stick the brush in the wall.

That shader I used as an example works, if you want to try it. The "1" decal texture should show up under Textures > Decals in the editor.