Jump to content

RGB light shader


Recommended Posts

Posted

i've been working on a small duel map and it needs light of course

so i found a texture that emits a blue light and decided to take a look at it's shader

 

textures/mp/s_bluestrip
{
q3map_lightimage textures/mp/s_bluestrip_blend.tga
qer_editorimage textures/mp/s_bluestrip.tga
q3map_surfacelight 3000
q3map_lightsubdivide 60
{
	map $lightmap
}
{
	map textures/mp/s_bluestrip
	blendFunc GL_DST_COLOR GL_ZERO
}
{
	map textures/mp/s_bluestrip_blend
	blendFunc GL_ONE GL_ONE
	rgbGen wave sin 0.85 0.005 0 10
}
}

 

i'm guessing it's the "rgbGen wave sin" line but not sure how it's works

as far as i konw RGB number need to hole numbers and not like the ones used in the line

 

so does it work like this: Red 0.85 Green 0.005 Blue 0 ? 10 < not sure what this is

or is it using some kind of other code?

Posted

I'm guessing it is how you describe, yes. The last one will be alpha prolly. The way to find out? SCIENCE. Go forth and test. =P

Posted

My limited understanding of shaders is that when colors are used, it is based on a 0 to 1 scale, not 0 to 255 like other types of color codes. The first three should be RGB and the fourth is... something I can't remember off the top of my head. I'm sure somebody can fill in the blank there. If in doubt you should be able to look it up.

Posted (edited)

BOOOO, shader manual. Throw it away. Who needs it. 0:) Now, no offense, you're quite far from the truth here...so let's see if I can help set the record straight.

 

Firstly, RGBGen Wave Sin is not what's casting light. q3map_surfacelight 3000 is. As I understand, the engine normally takes the color of the texture and casts it on the surroundings during the lighting compile, but in this case, it's using q3map_lightimage textures/mp/s_bluestrip_blend.tga for a value.

 

Second, About the 0-1 intensities, it's easy enough to work with. To get your RGB values from the shader's 0-1 values, multiply the number by 255. To get the RGB value to use in the shader from a normal 0-255 value, divide it by 255. You *CAN* use a number greater than 1, and it can have some fun effects - but it can also screw things up sometimes.

Or you can take the easy way out and view them as percentages, which is the intent anyway.

 

Third, those are not RGB values. RGBGen Wave sin is telling the engine to make the shader's RGB values oscillate, in a sine wave pattern. When you're using RGBGen Wave, you don't have control over the RGB values - just the overall brightness.

 

The first value is the initial brightness (base), the second is the amplitude (How much it will oscillate), the third is the phase (How far into the first oscillation it is when the engine begins rendering), and the fourth is the frequency (How fast/slow to oscillate).

 

I know nobody ever says this but I *HIGHLY* recommend trying out shaderED. A lot of the fun things become visually clear, like RGBGen and...well, RGBGen.

Edited by NAB622

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...