Game Development Community

Glow on lights

by PsychoParrot · in Torque Game Engine Advanced · 02/16/2007 (10:24 am) · 7 replies

Hey guys,

I'm new to this shader stuff and wondered if anyone could help me out with an effect I'm trying to achieve or let me know if I'm wayy off ...

I have a texture, with some 'lights' on it and I want them to glow. I assumed that the way to do this would be to have the 'standard' texture on the first channel, then apply a black and white image to the second and apply glow to it ... like this:

mapTo = "RED_WALL_A";
baseTex = "RED_WALL_A";
texture[1] = "RED_WALL_A_e";
glow[1] = true;
emmisive[1]=true;

(where _e is my glow texture, containing only glowing areas and the rest black ... and RED_WALL_A is just a standard wall texture)

Unfortunately, it just seems to apply the glow to the whole texture (ie. not just the mask texture on texture[1])...

Thanks in advance for any help you guys can give me,

Jeff.

#1
02/16/2007 (10:45 am)
Try turning off the emissive flag, as I believe that "cancels out" a lot of transparency stuff. Also, if your second texture has transparency, you should set translucent[1] = true. Also try setting specifying baseTex[0], just so it doesn't leave anything "to chance" with the engine.

Other than that.... Brian?
#2
02/16/2007 (11:43 am)
Thanks, Mark ... setting the translucent helped, as I can see the texture underneath now ;)

Only problem is that I don't see any glow ...
#3
02/16/2007 (12:52 pm)
Oh hey! The "texture" property looks like its only used for CustomMaterials. Try using baseTex[0] and then baseTex[1] for your alpha blend. Remember that glow uses the texture colour, so the "glowing" colour will be the non-black colour on that second texture.
#4
02/16/2007 (10:21 pm)
What I normally do is similar to what Mark is doing, though I normally just make a copy of the original picture, and then use the lasso tool in photoshop to cut away all the parts of the image that are not supposed to glow so you have a transparent image with only the area that is part of the light left. And then I make a material definition like this:

new Material(Sniper2)
{
   baseTex[0] = "~/data/shapes/weapons/sniper/snr2_map.dds";
   bumpTex[0] = "~/data/shapes/weapons/sniper/snr2_map_nm.dds";
   baseTex[1] = "~/data/shapes/weapons/sniper/snr2_map_glow.dds";
   pixelSpecular[0] = true;
   specular[0] = "0.5 0.5 0.5 0.5";
   specularPower[0] = 8.0;
      glow[1] = true;
//      Cubemap = WChrome;
      MapTo = "snr2_map";
};

You might also want to make emissive[1] = true but that right there works fine. Only the non-transparent areas on the second pass glow, and it allows for a colored glow.
#5
02/17/2007 (5:26 pm)
Thanks for the awesome help :)

I now have lots of pretty, glowy things all over the place!

You guys rock.
#6
02/19/2007 (7:18 am)
Actually, it seems rather a hack :(

I just noticed when changing the lighting setup of the level that whenever I add anything to baseTex[1] it suddenly stops being affected by the sglights in the level... almost as if it automatically has an emmisive or something??

I can't figure it out ... the only areas that should have emissive are those on channel 1, as I have this now:

baseTex[0] = "RED_WALL_A";
 baseTex[1] = "RED_WALL_A_e";
 emissive[0] = false;
 emissive[1] = true;
 translucent[1] = true;
 glow[1] = true;
 MapTo = "RED_WALL_A";

I removed the specular because it was just causing wayyy too much light on surfaces...

But, from my understanding, the code above says:

1. Set texture channel 0 to my standard wall texture.
2. Set texture channel 1 to a 'glow mask' texture (transparent png with some white areas on it)
3. Make sure emissive for channel 0 is off.
4. Make sure emissive for channel 1 is on.
5. Apply translucent to channel 1, to allow for my transparency.
6. Make channel 1 glow.
7. Map it to the original material.

Am I understanding this right?

Isn't it easy to spell emissive wrong? :p
#7
02/19/2007 (9:23 am)
Have you tried it without the emissive flag? I've done a few experiments with it and I usually get better results (more what I'm looking for) when I turn emissive off, even when I think what I'm doing should use it. (Princess Bride quote: "You keep using that word, I do not think it means what you think it means.")

Also, the "mapTo" parameter is redundant with baseTex[0], unless your art tool exports the texture references with the extension (like Maya). Also I assume you've already been through this article?