Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
KillPixel
Posts: 49 Joined: Sun Jun 22, 2014 7:35 pm
Post
by KillPixel » Wed Jun 25, 2014 11:26 pm
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.
[url=https://www.youtube.com/user/KillPixel]KillPixel@YouTube[/url]
Theftbot
Posts: 483 Joined: Thu Oct 08, 2009 4:03 am
Post
by Theftbot » Thu Jun 26, 2014 12:56 am
q3map_surfaceLight param.
obsidian
Posts: 10970 Joined: Mon Feb 04, 2002 8:00 am
Post
by obsidian » Thu Jun 26, 2014 2:05 am
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
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
KillPixel
Posts: 49 Joined: Sun Jun 22, 2014 7:35 pm
Post
by KillPixel » Thu Jun 26, 2014 3:19 am
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.
[url=https://www.youtube.com/user/KillPixel]KillPixel@YouTube[/url]
KillPixel
Posts: 49 Joined: Sun Jun 22, 2014 7:35 pm
Post
by KillPixel » Thu Jun 26, 2014 10:24 pm
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.
[url=https://www.youtube.com/user/KillPixel]KillPixel@YouTube[/url]
obsidian
Posts: 10970 Joined: Mon Feb 04, 2002 8:00 am
Post
by obsidian » Fri Jun 27, 2014 2:45 am
What's the second stage for? Why not just combine the textures for door_on and door_light?
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
Theftbot
Posts: 483 Joined: Thu Oct 08, 2009 4:03 am
Post
by Theftbot » Fri Jun 27, 2014 4:10 am
What engine is that?
KillPixel
Posts: 49 Joined: Sun Jun 22, 2014 7:35 pm
Post
by KillPixel » Fri Jun 27, 2014 5:20 am
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
[url=https://www.youtube.com/user/KillPixel]KillPixel@YouTube[/url]
obsidian
Posts: 10970 Joined: Mon Feb 04, 2002 8:00 am
Post
by obsidian » Fri Jun 27, 2014 5:40 am
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
}
}
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
KillPixel
Posts: 49 Joined: Sun Jun 22, 2014 7:35 pm
Post
by KillPixel » Fri Jun 27, 2014 9:28 am
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.
[url=https://www.youtube.com/user/KillPixel]KillPixel@YouTube[/url]