Transparent Materials on DIFs Using translucent = true
by Thomas Phillips · in Torque Game Engine Advanced · 10/03/2006 (9:39 pm) · 14 replies
My understanding of the materials.cs file is that the following line will enable alpha shading for textures with transparencies:
translucent = true ;
Should this also work for DIF files? If not, is there a way to enable the alpha in textures with transparencies for DIFs?
Tom
translucent = true ;
Should this also work for DIF files? If not, is there a way to enable the alpha in textures with transparencies for DIFs?
Tom
#2
10/05/2006 (1:45 am)
It works fine for Dif files, with no modification. Although if you use a refraction effect on the surface remember that it won't display the water or most other zbuffer effects beneath it.
#3
GALAHAD: Blue. No yel-- Auuuuuuuugh!
I'm getting mixed messages here... I guess there are really two questions. Should transparent materials work in DIFs (in TSE), and do they really work now?
I recalled seeing the TGE mod for enabling alpha, but I thought that was moot after the rendering code was re-written. In practice, we are seeing the translucent tag work for DTS materials, but not DIF materials. I don't know if that's normal, a TSE bug, or we're just doing something wrong.
Has anyone actually gotten a TSE DIF displaying transparent materials using the translucent (or any other) material value?
Tom
10/05/2006 (7:07 am)
KEEPER: What is your favorite color?GALAHAD: Blue. No yel-- Auuuuuuuugh!
I'm getting mixed messages here... I guess there are really two questions. Should transparent materials work in DIFs (in TSE), and do they really work now?
I recalled seeing the TGE mod for enabling alpha, but I thought that was moot after the rendering code was re-written. In practice, we are seeing the translucent tag work for DTS materials, but not DIF materials. I don't know if that's normal, a TSE bug, or we're just doing something wrong.
Has anyone actually gotten a TSE DIF displaying transparent materials using the translucent (or any other) material value?
Tom
#4
Obviously Mincentro has so it probably works. It is not that hard to try yourself so why not try?
10/05/2006 (7:58 am)
Quote:
Has anyone actually gotten a TSE DIF displaying transparent materials using the translucent (or any other) material value?
Obviously Mincentro has so it probably works. It is not that hard to try yourself so why not try?
#5
I can't be more plain than that. ;-) I'll assume, then, that either we have an error in our art pipeline, or there is a bug in TSE (pulled last Saturday, I believe). Does anyone have any ideas on the best way to debug this?
@Mincetro
Did you have to do anything other than use the translucent tag to enable texture transparencies on the DIFs?
Tom
10/05/2006 (6:46 pm)
I wrote,Quote:
In practice, we are seeing the translucent tag work for DTS materials, but not DIF materials. I don't know if that's normal, a TSE bug, or we're just doing something wrong.
I can't be more plain than that. ;-) I'll assume, then, that either we have an error in our art pipeline, or there is a bug in TSE (pulled last Saturday, I believe). Does anyone have any ideas on the best way to debug this?
@Mincetro
Did you have to do anything other than use the translucent tag to enable texture transparencies on the DIFs?
Tom
#6
10/05/2006 (7:49 pm)
I just tested it using the following material definitionnew Material(walltex_1)
{
mapTo = walltex_1;
baseTex[0] = "walltex_1";
bumpTex[0] = "walltex_1_normal";
translucent = true;
pixelSpecular[0] = true;
specular[0] = "1.0 1.0 1.0 0.7";
specularPower[0] = 64.0;
};and it worked fine for me on both .dif and .dts objects. Does the material have an Alpha channel?
#7
Yep, they're using a PNG with transparency. However, I took a look at the file and they have all RGB set to 255. Maybe it only works when RGBA are all within certain ranges? We're experimenting now with different values, so hopefully we'll find something that works.
Tom
10/06/2006 (6:54 pm)
Thanks for the sample material settings. I passed it on and they're now using that as a reference.Yep, they're using a PNG with transparency. However, I took a look at the file and they have all RGB set to 255. Maybe it only works when RGBA are all within certain ranges? We're experimenting now with different values, so hopefully we'll find something that works.
Tom
#8
The original texture we used was (I think) RGB all 255 with some arbitrary setting for the alpha. Perhaps the alpha was out of bounds (maybe too much or too little alpha is possible). Perhaps RGB = 255,255,255 pixels doesn't work with transparency. In any case, we've gotten it to work now and it's just a matter of experimentation to get the materials looking the way we want them. Again, thanks for your help.
Tom
10/06/2006 (11:54 pm)
We finally have it working. Thank you very much, Mincetro, for giving us a reference to work from. It seems that some combinations of RGBA are valid, and others are not. We're still not sure what TSE is really expecting for these values. If anyone knows, please chime in.The original texture we used was (I think) RGB all 255 with some arbitrary setting for the alpha. Perhaps the alpha was out of bounds (maybe too much or too little alpha is possible). Perhaps RGB = 255,255,255 pixels doesn't work with transparency. In any case, we've gotten it to work now and it's just a matter of experimentation to get the materials looking the way we want them. Again, thanks for your help.
Tom
#9
10/07/2006 (2:00 am)
So you had to use the alpha channel? Interesting, it always worked here without.
#10
We had always used the alpha channel, but apparently only certain combinations of values work. Since the art pipeline is a bit drawn out, and we've got people scattered all over, troubleshooting what works and what doesn't (and why) is a bit of a hassle.
Tom
10/07/2006 (8:08 am)
Not sure how to read that, Stefan. Your earlier post seemed to imply you had not used transparent materials on DIFs in TSE. I probably misread it, but no matter now since we've finally got something working.We had always used the alpha channel, but apparently only certain combinations of values work. Since the art pipeline is a bit drawn out, and we've got people scattered all over, troubleshooting what works and what doesn't (and why) is a bit of a hassle.
Tom
#11
Also, the "Window_Alpha" texture is a 24-bit png with a flat transparent image. This was created in photoshop using a layer mask on one flat layer. It doesnt work if you simply set the transparency on the layer. If you do that you can just create a blank layer under it and merge down so the layer transparency is still at 100%.
I believe the whole materials.cs should have some more in-depth documentation. There is some syntax that seems to work for MS3 but not MS4 and the material.cs explanation on the wiki seems to skip some steps. Can anyone from GG explain exactly whats going on with the materials?
10/10/2006 (8:36 pm)
I've tried the code listed above and it doesn't work for me without some edits. For some reason the texture index for the specular mapping has to be set to "1" not "0" for it to work. If its set to zero or if the specular variables in the material are omitted then nothing shows up (texture is completely invisible). I assume this deals with different render passes for the texture, but I don't believe it was mentioned on the TDN. Below is the material setup that work for transparent textures:new Material( Window_Alpha ) {
mapTo = Window_Alpha;
baseTex[0] = "Window_Alpha";
bumpTex[0] = "Window_Alpha_bump";
translucent = true;
pixelSpecular[1] = true;
specular[1] = "1.0 1.0 1.0 0.5" ;
specularPower[1] = 6.0 ;
};Also, the "Window_Alpha" texture is a 24-bit png with a flat transparent image. This was created in photoshop using a layer mask on one flat layer. It doesnt work if you simply set the transparency on the layer. If you do that you can just create a blank layer under it and merge down so the layer transparency is still at 100%.
I believe the whole materials.cs should have some more in-depth documentation. There is some syntax that seems to work for MS3 but not MS4 and the material.cs explanation on the wiki seems to skip some steps. Can anyone from GG explain exactly whats going on with the materials?
#12
For starters, if you have the transparency set through the layer opacity... won't work. The Layer Opacity has to be at 100%. We were just using a 128x128 solid white texture to use for frosted glass on a light globe. So what we had to do was drop a transparent layer under it and merge it down. Alpha Masks didn't work, neither did "Save for Web" in Photoshop CS2.
Then we discovered the whole materials.cs issue. After trying numerous combinations, different methods of saving PNG files, modifying the materials.cs this is our only way of working it.
Now if we used baseTex[0] it wouldn't work, if we used quotes, it didn't work. The above is the only way that we have been able to get transparencies on DIF models at all, and of course that all vanishes once we fire and exploding crossbow from the handy Orc Doombow.
Some of you guys may be having an easier time with the materials.cs, kudos cause we sure haven't. One minute somethign works, we change the material to disable it, then when we change it back to how it worked before... doesn't work. Even though nothing else at all was changed.
Just getting this up there in the event that someone else is having troubles and doesn't want to spend hours trying various combinations. Hope this helps out someone else.
10/22/2006 (12:17 am)
Actually the above only worked for one DIF. The only way we got it to work regularly was with the example below. We've experienced a GREAT anount of inconsistency with the materials.cs between DIFs and DTS files, and witht he lack of documentation it took us three hours to get that far.For starters, if you have the transparency set through the layer opacity... won't work. The Layer Opacity has to be at 100%. We were just using a 128x128 solid white texture to use for frosted glass on a light globe. So what we had to do was drop a transparent layer under it and merge it down. Alpha Masks didn't work, neither did "Save for Web" in Photoshop CS2.
Then we discovered the whole materials.cs issue. After trying numerous combinations, different methods of saving PNG files, modifying the materials.cs this is our only way of working it.
new Material( MaterialName ) {
mapTo = Texture;
baseTex = Texture;
translucent = true ;
pixelSpecular[1] = true ;
specular[1] = "1.0 1.0 1.0 1.0" ;
specularPower[1] = 64.0 ;
};Now if we used baseTex[0] it wouldn't work, if we used quotes, it didn't work. The above is the only way that we have been able to get transparencies on DIF models at all, and of course that all vanishes once we fire and exploding crossbow from the handy Orc Doombow.
Some of you guys may be having an easier time with the materials.cs, kudos cause we sure haven't. One minute somethign works, we change the material to disable it, then when we change it back to how it worked before... doesn't work. Even though nothing else at all was changed.
Just getting this up there in the event that someone else is having troubles and doesn't want to spend hours trying various combinations. Hope this helps out someone else.
#13
I think also that a lot of your issues are due to Photoshop having messed up .png alpha channel support. This massively affects how the shaders draw the Materials, especially when translucent. This thread covers some of the issues:
http://www.garagegames.com/mg/forums/result.thread.php?qt=29617
I'm writing docs on translucent materials as well, I'll let everyone know when they're ready.
10/23/2006 (3:42 pm)
@ SRO - I'm writing some docs on Materials and mapping them properly which I think will help explain things much better. I'll post when those go up. I think also that a lot of your issues are due to Photoshop having messed up .png alpha channel support. This massively affects how the shaders draw the Materials, especially when translucent. This thread covers some of the issues:
http://www.garagegames.com/mg/forums/result.thread.php?qt=29617
I'm writing docs on translucent materials as well, I'll let everyone know when they're ready.
#14
TranslucentBlendOp =; //In most cases "lerpAlpha" has worked for me
10/25/2006 (1:28 pm)
Translucent = true;TranslucentBlendOp =
Torque Owner Stefan Lundmark