Quake3World.com Forums
     Level Editing & Modeling
        Light Emitting Shaders


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Light Emitting Shaders

Trainee
Trainee
Joined: 22 Jun 2014
Posts: 49
PostPosted: 06-25-2014 03:26 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
KillPixel@YouTube


Top
                 

Theftbot
Theftbot
Joined: 07 Oct 2009
Posts: 483
PostPosted: 06-25-2014 04:56 PM           Profile Send private message  E-mail  Edit post Reply with quote


q3map_surfaceLight param.




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 06-25-2014 06:05 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

Trainee
Trainee
Joined: 22 Jun 2014
Posts: 49
PostPosted: 06-25-2014 07:19 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
KillPixel@YouTube


Top
                 

Trainee
Trainee
Joined: 22 Jun 2014
Posts: 49
PostPosted: 06-26-2014 02:24 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
KillPixel@YouTube


Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 06-26-2014 06:45 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

Theftbot
Theftbot
Joined: 07 Oct 2009
Posts: 483
PostPosted: 06-26-2014 08:10 PM           Profile Send private message  E-mail  Edit post Reply with quote


What engine is that?




Top
                 

Trainee
Trainee
Joined: 22 Jun 2014
Posts: 49
PostPosted: 06-26-2014 09:20 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
KillPixel@YouTube


Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 06-26-2014 09:40 PM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

Trainee
Trainee
Joined: 22 Jun 2014
Posts: 49
PostPosted: 06-27-2014 01:28 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
KillPixel@YouTube


Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.