Author Topic: Some help clearing up shaders  (Read 3490 times)

Relish

  • Posts: 34
  • Turrets: +1/-6
Some help clearing up shaders
« on: July 03, 2010, 07:02:06 am »
I am making a map (or trying) and all I can effectively use is a lamp for light, but I want to make a glowing logo/emblem on the wall that will look really cool and also emit light against the scenery.  I found a somewhat decent explanation here: http://www.quake3world.com/forum/viewtopic.php?f=10&t=42381  And if you are too lazy to look here is the code:
Code: [Select]
models/mapobjects/lamp745
{
      q3map_lightimage models/mapobjects/lamp745/li.tga
      // this TGA is the source for the color of the blended light

      q3map_surfacelight 10000
      //emitted light value of 10,000

      {
         map $lightmap
         //source texture is affected by the lightmap
         rgbGen identity
         // this command handles the overbright bits created by "sunlight"
         // in the game
      }
      {
         map models/mapobjects/lamp745/tex.tga
         blendFunc filter
         rgbGen identity
      }
      {
         map models/mapobjects/lamp745/li.tga
         blendFunc add
      }
}

I have a few questions about this stuff.
First.... 
Code: [Select]
{
         map models/mapobjects/lamp745/tex.tga
         blendFunc filter
         rgbGen identity
      }
What does this do and why is it in there and what is it modifying?
And second....
Code: [Select]
{
         map models/mapobjects/lamp745/li.tga
         blendFunc add
      }
What does this do and why is it in there and what is it modifying?

And third.... When you see a { and then a map command, what exactly does this do?  My guess is tex mapping but there are 3 calls to this so I am confused.

And forth.... What does blendFunc add do?

God, maker of the world

  • Guest
Re: Some help clearing up shaders
« Reply #1 on: July 03, 2010, 07:30:30 am »
Maybe someone can give a detailed answer. Until then, let me give you the link to a good shader manual:

http://www.heppler.com/shader/

MrFish

  • Posts: 201
  • Turrets: +16/-500
Re: Some help clearing up shaders
« Reply #2 on: July 03, 2010, 07:31:00 am »
I'm not sure what each { } does but the way I've been treating them (and it's worked for me so far) is as a layer. However I'm almost sure it is not it acts likes one and it has worked for me. I'll explain in a bit.

map means -get this texture. So the path that comes after it is a path to a texture. A tga file is a texture file that contains transparencies. Same as a png but pngs don't work in netradiant for whatever reason. And since tga files are massive in comparison to jpgs, Use jpgs unless part of the texture should be transparent.

blendFunc is used to make part of the texture transparent. If you save a tga file with transparent space it will automatically (well it should anyway) create an alpha layer that is black and white (you can't see this). The white on the alpha layer is usually the opaque (visible) pixels on your texture and the parameter you use after blendFunc or alphaFunc will subtract the pixels that aren't sitting on the white in the alpha layer.



Now again I don't know what the { } actually mean but I think of them like layers. Let me give you an example-

Code: [Select]
textures/my_map/ashader
{
   map textures/my_map/firstlayer.jpg
   //ashader really has no texture with that name. so lets give it a texture so it doesn't show up as "notexture" in the game
   {
      map textures/my_map/aball.tga
      //Now go get this texture
      blendFunc blend
      //Remove pixels of aball.tga that are transparent and place this on top
      
      tcMod scale .5 .5
      //make this top texture twice as big
   }
   {
      map textures/my_map/sparkles.tga
      
      etc...
   }
}

The first texture will be firstlayer.jpg that might look like this-



Second texture-



Final results (remember, tcMod scale made the second texture twice as big)-



And you can continue to add more layers.

Relish

  • Posts: 34
  • Turrets: +1/-6
Re: Some help clearing up shaders
« Reply #3 on: July 03, 2010, 06:39:56 pm »
Thanks MrFish you helped a lot.

Here is an edit: I can make it look like it glows but I cant make it light the room.  Can you tell me how to do this?  Here is my current shader:
Code: [Select]
textures/relish/heart-light

{

qer_editorimage textures/relish/heart-light.tga

surfaceparm nomarks

q3map_surfacelight 50000

{

map textures/relish/heart-light.tga
blendfunc blend

}

{

map $lightmap

rgbGen identity

}

{

map textures/relish/heart-light.tga

blendfunc add

}

}
« Last Edit: July 08, 2010, 08:20:46 pm by Relish »

MrFish

  • Posts: 201
  • Turrets: +16/-500
Re: Some help clearing up shaders
« Reply #4 on: July 08, 2010, 08:30:43 pm »
Surface light does not radiate light from the shader. That is just how much light appears to be shining on the texture. Look into the shader manual to see if you can radiate light anywhere. If not, an easy fix is to just put a light source with the color you want right in front of it.

God, maker of the world

  • Guest
Re: Some help clearing up shaders
« Reply #5 on: July 09, 2010, 04:28:23 am »
Quote from: MrFish
Surface light does not radiate light from the shader. That is just how much light appears to be shining on the texture.

Not true according to my experience. Adding surfacelight creates light in the q3map2 light pass.

http://www.heppler.com/shader/shader/section4.htm#4.5

Quote
4.5 q3map_surfaceLight <light value>
The texture gives off light equal to the <light value> set for it. The relative surface area of the texture in the world affects the actual amount of light that appears to be radiated. To give off what appears to be the same amount of light, a smaller texture must be significantly brighter than a larger texture. Unless the qer_lightimage keyword is used to select a different source for the texture's light color information, the color of the light will be the averaged color of the texture.

MrFish

  • Posts: 201
  • Turrets: +16/-500
Re: Some help clearing up shaders
« Reply #6 on: July 09, 2010, 08:23:04 am »
Ok, listen to gmotw. He knows more then me :P

God, maker of the world

  • Guest
Re: Some help clearing up shaders
« Reply #7 on: July 09, 2010, 09:20:47 am »
You can also look at light shaders as they are used in the default 1.1.0 maps, they demonstrate pretty well how you can make a light emitting shader.

Also, this tutorial explicitly states:

http://tremmapping.pbworks.com/Starting-Tremulous-Mapping#Shaders

Quote
q3map_surfacelight 1250 //This is the setting that makes the texture emit light
« Last Edit: July 09, 2010, 09:23:57 am by God, maker of the world »