Page 1 of 1
Light Emitting Shaders
Posted: Wed Jun 25, 2014 11:26 pm
by KillPixel
It seems the info I'm looking for is not yet in the manual:
http://q3map2.robotrenegade.com/docs/sh ... aders.html
Here are the textures and shaders I'm using for this example:
Code: Select all
textures/tech/door
{
q3map_lightimage textures/tech/door_on.tga
surfaceparm nodlight
surfaceparm nomarks
{
map textures/tech/door.tga
}
{
map $lightmap
blendFunc filter
}
{
map textures/tech/door_on.tga
blendfunc blend
}
}
...and an example of them in action:
http://www.killpixel.com/kpcn/wide_door.jpg
The light emitted by the red lights on the door is from two red lights I placed in the editor, I'd like to do this via shaders if possible. I'm not very shader savvy, so example code that I can cannibalize would be great
I was hoping I could just add a few lines to the 3rd stage for it to work, but maybe I'm being naive.
Re: Light Emitting Shaders
Posted: Thu Jun 26, 2014 12:56 am
by Theftbot
q3map_surfaceLight param.
Re: Light Emitting Shaders
Posted: Thu Jun 26, 2014 2:05 am
by obsidian
surfaceLight works well if you wanted the entire surface to emit light (like an actual light fixture texture), but not so well if you just have a tiny glowing texture.
Instead of creating a real light source, you probably want to fake it for small stuff like this with an additive blend (blendFunc add) on that last stage.
It would probably look better if that door_on.tga image had a slight blur/halo on it as well.
See here:
http://q3map2.robotrenegade.com/docs/sh ... #blendFunc
Optionally, you can also add a bit of a pulse to it by changing the vertex colour values with a waveform function:
http://q3map2.robotrenegade.com/docs/sh ... tml#rgbGen
Re: Light Emitting Shaders
Posted: Thu Jun 26, 2014 3:19 am
by KillPixel
ok, using blendfunc add for the glow works, using this image:
However, I don't know how to stack this on along with door_on. I can do each one separately, but having them both is tricky
EDIT: nvm, figured it out and it looks good! Thanks again, obsidian.
Re: Light Emitting Shaders
Posted: Thu Jun 26, 2014 10:24 pm
by KillPixel
Well, I thought I had it figured out...
Code: Select all
textures/tech/door
{
q3map_lightimage textures/tech/door_on.tga
surfaceparm nodlight
surfaceparm nomarks
{
map textures/tech/door.tga
}
{
map $lightmap
blendFunc filter
}
{
map textures/tech/door_on.tga
blendfunc blend
}
{
map textures/tech/door_light.tga
blendfunc add
}
}
And the result:
http://www.killpixel.com/kpcn/wtf.jpg
As you can see, it makes the door bright. Would you show me the error of my ways?
EDIT: Nvm, again. I had to specify rgbGen identity
Code: Select all
textures/tech/door
{
surfaceparm nodlight
surfaceparm nomarks
{
map textures/tech/door.tga
}
{
map $lightmap
rgbGen identity
blendFunc filter
}
{
map textures/tech/door_on.tga
blendfunc blend
}
{
map textures/tech/door_light.tga
blendfunc add
}
}
The manual led me astray:
rgbGen identity: Colors are assumed to be all white (1.0, 1.0, 1.0). All filters stages (lightmaps, etc) will get this by default.
Re: Light Emitting Shaders
Posted: Fri Jun 27, 2014 2:45 am
by obsidian
What's the second stage for? Why not just combine the textures for door_on and door_light?
Re: Light Emitting Shaders
Posted: Fri Jun 27, 2014 4:10 am
by Theftbot
What engine is that?
Re: Light Emitting Shaders
Posted: Fri Jun 27, 2014 5:20 am
by KillPixel
What's the second stage for? Why not just combine the textures for door_on and door_light?
Because I don't know wtf I'm doing
light_on needs to be fully opaque and fullbright, light_glow needs to be translucent. I don't know how to do that with one texture.
What engine is that?
FTE
Re: Light Emitting Shaders
Posted: Fri Jun 27, 2014 5:40 am
by obsidian
Textures should look something like this:
Code: Select all
textures/tech/door
{
surfaceparm nomarks
{
map textures/tech/door.tga
}
{
map $lightmap
rgbGen identity
blendFunc filter
}
{
map textures/tech/obs_door_light.tga
blendFunc add
}
}
Re: Light Emitting Shaders
Posted: Fri Jun 27, 2014 9:28 am
by KillPixel
Awesome, much better. I was using an alpha channel and blendfunc blend for door_on because I thought blendfunc add would blend in the door texture... that would be the case if the door texture directly behind door_on wasn't black. Derp, that escaped me.
Sweet, less code, one less texture and no alpha channel.
Thanks again.