Game Development Community

[Help] - Transparency Problem

by Nicolai Dutka · in Artist Corner · 10/21/2009 (11:37 pm) · 7 replies

I'm trying to make a 'corner shower' with glass doors. I've got a diffuse, normal, and alpha map. This is how my object looks in Max:

i195.photobucket.com/albums/z83/kingdutka/shower.png

Now when I export the mesh without any opacity/transparency (no alpha map), it looks like this in game:

i195.photobucket.com/albums/z83/kingdutka/screenshot_005-00000.png

And then when I add the alpha map:

i195.photobucket.com/albums/z83/kingdutka/screenshot_004-00000.png

I've also tried playing around with the materials.cs file. If I export the mesh with NO alpha and use:
new Material(shower){
  baseTex[0] = "./shower_D";
  bumpTex[0] = "./shower_N";
  translucent = true;
};

Then it shows up like image 3 above, even though there is no alpha map...

If I comment out the last line 'translucent = true;', then it shows up like image 2 above.

I can't for the life of me figure out how to get my transparency to work...

I do have an object in my game right now that is 100% transparent, but it also has no diffuse or normal map, it's an invisible object...

#1
10/22/2009 (7:39 am)
You should start by separating all of your transparent geometry from the opaque geometry within the model and then create a texture for each set. That is segment your model and then build separate textures for the glass and one for the solid mesh parts. You can combine both types onto the same texture but Torque still doesn't handle alpha masks very well and separating them should rid you at least of some of the problems you're experiencing.

Good luck.
#2
10/22/2009 (11:49 am)
Already did try that... I did a 'detach' on the glass doors and applied a different texture and now the doors come in solid black while the rest of the mesh is fine...

I'm starting to think there is a problem with my exporter... I'm using Max 2010. I'm using this exporter: www.garagegames.com/community/resources/view/18261
#3
10/22/2009 (12:34 pm)
Ok, I did finally get this figured out!

I detached the glass from the rest of the shower as a separate object, then I made an exact copy of the texture i had been using and just renamed it. Then to get the normals to show up, I had to assign materials:

new Material(shower){
  baseTex[0] = "./shower_D";
  bumpTex[0] = "./shower_N";
};

new Material(showerGlass){
  baseTex[0] = "./showerGlass_D";
  bumpTex[0] = "./showerGlass_N";
  translucent = true;
};

The first picture in the first post is now what the shower looks like in the game! :D
#4
10/22/2009 (12:37 pm)
In the datablock for the shader try a sequenced setup instead of numbering all the texture entries as 0. So it looks like this;

1. new Material(shower){
2. baseTex[0] = "./shower_D";
3. bumpTex[1] = "./shower_N";
4. translucent = true;
5. };

or
1. new Material(shower){
2. baseTex[1] = "./shower_D";
3. bumpTex[2] = "./shower_N";
4. translucent = true;
5. };
#5
10/22/2009 (12:45 pm)
Tried that and it didn't work at all... The whole object turned black.


Look at post #3 though, I got it. ;)
#6
10/22/2009 (12:46 pm)
If the glass is showing transparent then your transparencies are working. If the problem is the darkening of the opaque geometry check your texture settings in the Material Editor of Max for errors. Check the light value setting, make sure its set to 100. Also check to see if the alpha channel settings got reset when you separated the glass from the opaque geometry. Sometimes, when you build a texture with an alpha channel and go back and separate out the geometry sets the original set still has the alpha channel setting working when they should be reset to zero values.

Something else you can try with the shader datablock is to use the complete name of the texture in the first line, like this; 1. newMaterial(shower_D){

I can't say for sure what effect this will have but in the past using the complete texture name has cleared up some errors I've experienced.
#7
10/22/2009 (12:47 pm)
Again, please look at post #3................
#8
10/22/2009 (12:47 pm)
OK, cool!