Quake3World.com
https://www.quake3world.com/forum/

Light Emitting Shaders
https://www.quake3world.com/forum/viewtopic.php?f=10&t=50347
Page 1 of 1

Author:  KillPixel [ 06-25-2014 03:26 PM ]
Post subject:  Light Emitting Shaders

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:

Image

Code:
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.

Author:  Theftbot [ 06-25-2014 04:56 PM ]
Post subject:  Re: Light Emitting Shaders

q3map_surfaceLight param.

Author:  obsidian [ 06-25-2014 06:05 PM ]
Post subject:  Re: Light Emitting Shaders

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

Author:  KillPixel [ 06-25-2014 07:19 PM ]
Post subject:  Re: Light Emitting Shaders

ok, using blendfunc add for the glow works, using this image:

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.

Author:  KillPixel [ 06-26-2014 02:24 PM ]
Post subject:  Re: Light Emitting Shaders

Well, I thought I had it figured out...

Code:
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:
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:

Quote:
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.

Author:  obsidian [ 06-26-2014 06:45 PM ]
Post subject:  Re: Light Emitting Shaders

What's the second stage for? Why not just combine the textures for door_on and door_light?

Author:  Theftbot [ 06-26-2014 08:10 PM ]
Post subject:  Re: Light Emitting Shaders

What engine is that?

Author:  KillPixel [ 06-26-2014 09:20 PM ]
Post subject:  Re: Light Emitting Shaders

Quote:
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 :D

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.

Quote:
What engine is that?


FTE

Author:  obsidian [ 06-26-2014 09:40 PM ]
Post subject:  Re: Light Emitting Shaders

Textures should look something like this:

Image


Code:
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
   }   
}

Author:  KillPixel [ 06-27-2014 01:28 AM ]
Post subject:  Re: Light Emitting Shaders

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. :cool: :up:

Thanks again.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/