Game Development Community

Glow mask?

by Helk · in Torque 3D Professional · 07/23/2009 (6:58 pm) · 19 replies

Hey guys, I've been doing a glow mask like this :

new Material(WallMetal1c)
{
mapTo = "WallMetal1c";
diffuseMap[0] = "art/interiors/HP/WallMetal1c";
normalMap[0] = "art/interiors/HP/WallMetal1c_NRM";
specular[0] = "1 1 1 0.1";
specularPower[0] = "32";
pixelSpecular[0] = "1";

diffuseMap[1] = "art/interiors/HP/WallMetal1c_glow";
glow[1] = "1";
emissive[1] = "1";
};

and it's worked, (the second layer glows, the first layer looks normal) but in Beta 4, this material no longer casts shadows, like it's not rendered in the shadow pass, any help on how to fix this or how to 'properly' mask a material for glowing?

p.s. the glow diffuseMap is basically black, with white spots where i want it to glow

#1
07/23/2009 (7:28 pm)
I see why this would be broken. I will fix this in trunk.

materialDefinition.cpp, change isEmissive to this:
bool Material::isEmissive() const 
{
   bool ret = true;
   for( U32 i=0; i<MAX_STAGES; i++ )
      ret &= mEmissive[i];
   return ret;
}

Edit: This will fix the shadow issue, but the larger issue here, I think, is artist controllable glow. Maybe some sort of "glowMap" would actually be much better. Instead of masking glow, you would make an RGB texture which would be used in place of the regular texture for the glow pass. This seems like it could really help do cooler things with glow.

EDIT2: NOTE. On further thought, the above fix, while it fixes this issue, is still not the proper fix, because it is testing stages which may not have been initialized, which would essentially make 'isEmissive' never return true. This is not the proper and final fix, I will post that when I get back to this issue.
#2
07/23/2009 (11:50 pm)
It would be cool to be able to make transparent materials glow also. I am not sure if I am doing something wrong or not but Ive fooled with all of the transparent params and just 1 of them will allow for glow to show up which is the 'None' option. It would also be cool be able to control how much glow is on certain materials.
#3
07/24/2009 (10:05 am)
Pat, that solved the issue thanks. I think spec masking, glow masking etc should be combined into a single texture where RGB each handle a mask type
#4
07/24/2009 (10:08 am)
Helk,
I am glad that solved the issue. I disagree on combining glow and specular into the same mask, though. The reason is, the specular map needs all 4 channels, RGBA, for specular color [rgb] and (optionally) specular power/exponent in Alpha.

I will see if I can improve this functionality.
#5
07/24/2009 (11:43 am)
I thought you could calf specilar based on light color, specular amount (mask) and diffuse color, what circumstance would require setting a specific specilar color from a mask that you could not generate from the aformentioned data
#6
07/24/2009 (11:57 am)
Think of CDs, DVDs, soap bubbles. all have color spec. Most game engines use this arrangement.
#7
07/24/2009 (12:40 pm)
James, you are actually describing a thin-film refraction effect, not a specular highlight for those particular surfaces.

Helk, the color of a specular highlight is determined mostly by the material, and not by the color of the light, except in the cases of metallic materials and some ceramic materials. For most game engines, either forward shaded, or deferred shaded, there is no light color contribution in specular.
#8
09/08/2009 (7:01 pm)
Hey Helk, can you advise me what the maps are that you are using.

Layer0
Diffuse RGB (COLOR)


Layer1
Diffuse RGB (GLOW MASK)


I'm trying to do the same thing you have above in Beta5 but all I get is the Layer1 material to render.

Thanks

www.bitSlap.me/GlowThreadBeta5.png
#9
09/08/2009 (9:49 pm)
..does your layer1 diffuse map have an alpha channel ?

//edit: ah, ok, saw the other thread. Glad it's sorted!
#10
09/08/2009 (9:56 pm)
@Pat is there anyway to cast the shadow if Layer0 is non-emmisive making Layer1 to 3 not effect the shadow system I know this not best but works for the glow effect on chars now a days. Any thoughts.


@eb Thanks, just figured it out the hard way.

Tested the channels with a fake alpha and figured the rest out.

www.bitSlap.me/GlowMaskTest.jpg


www.bitSlap.me/GlowMask.jpg
Thanks

EDIT: lol if you read the email the links.
#11
09/09/2009 (1:24 am)
Next release should actually remove that "emissive" turn off of shadowing. Instead there is just an option to disable the shadow.
#12
09/09/2009 (1:42 am)
Sweet thanks for the info Pat!
#13
09/09/2009 (6:01 pm)
Also most likely in 1.1 or 1.2 the old "glow buffer" style glow will go away and be replaced by the bloom pass as part of HDR. It produces the same result without extra draw calls, special materials, another rendertarget, and two more gaussian blurs.

Even better as we add more complex bloom filters with star effects they will work with all light sources including emissive or glowing pixels.
#14
09/09/2009 (6:16 pm)
Awesome^Awesome! Thanks for the heads up Tom!
#15
02/27/2010 (2:32 am)
So i was wondering If I am understanding this correctly, layer 0 needs your regular diffuse with an alpha channel that consist of nothing but white and on layer 1 you place your actual emmisive map which is all black except for the portions of your map that is needing to emmit light ? This may be something very simple I am just trying to figure this out because right now I am in the process of creating some stained glass windows in torque and I need the illusion of light coming through them with a emmisive map.I would greatly appreciate the help :)
#16
02/27/2010 (9:30 am)
@john: not quite. Place your diffuse on stage 0 and the emissive map with transparency on stage 1. set emissive and glow for stage 1 to true and you should be set.
#17
02/27/2010 (1:03 pm)
I will try it out in a few, thanks a lot man I really appreciate you taking the time to help out !
#18
03/07/2010 (1:35 pm)
so i def have the glow working now on layer 1 but an issue I am having now is that my normal map for the glowing parts are not showing up anymore. Does this glow mask pretty much destroy the normal map from layer 0 ?
#19
07/03/2010 (12:10 am)
Any suggestions on reading material for how to this Glow Mapping?