All right, what am I doing wrong here? Alpha mapping
by Rick Austinson · in Torque Game Engine Advanced · 06/04/2009 (10:52 pm) · 16 replies
So I get that I'm supposed to embed alpha maps in the .DDS files, but what is the trick to doing that?
You've got DXT1 with 1 bit alpha, DXT3 with explicit alpha, and DXT5 with Interpolated alpha. All 3 in-game yield some level of not being alpha at all.
So what is the trick to alpha mapping?
You've got DXT1 with 1 bit alpha, DXT3 with explicit alpha, and DXT5 with Interpolated alpha. All 3 in-game yield some level of not being alpha at all.
So what is the trick to alpha mapping?
#2
06/05/2009 (11:22 am)
I read the docs on materials, didn't see anything mentioning alpha and DDS. Where/how does one set the alpha channel to be translucent? I spent some time digging through the materials docs again and googleing it, all I found was a TDN page on shaders which only talked about PNGs.
#3
eg:
file:///C:/Torque/TGEA_1_8_1/documentation/content/documentation/Materials%20and%20Shaders/Materials.html#Translucent
Here's a starter for transparency on script, alpha channel transparency won't work without it:
06/05/2009 (12:18 pm)
Docs come with the engine too. eg:
file:///C:/Torque/TGEA_1_8_1/documentation/content/documentation/Materials%20and%20Shaders/Materials.html#Translucent
Quote:in order to use this channel you must use .png or some other supported 32 bit file format for the texture.DDS is a supported 32 bit file. Create an extra channel and it will automatically be an alpha unless you stipulate otherwise (give it another name). Refer to your graphics/image software docs on how to do this.
Here's a starter for transparency on script, alpha channel transparency won't work without it:
new Material(abranch1)
{
mapTo = "abranch1";
basetex[0] = "abranch1";
emissive[0] =false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192; // anything below this number is not visible and is not written to zbuffer
};
#4
Thank you for your help, it all makes sense now.
Except... can you tell me where that piece of code is supposed to go? That would be helpful.
Thanks,
Rick
06/05/2009 (5:06 pm)
See, now theres what I was missing! I figured it was something like that. Thank you for your help, it all makes sense now.
Except... can you tell me where that piece of code is supposed to go? That would be helpful.
Thanks,
Rick
#5
06/05/2009 (6:43 pm)
Put it in a material.cs file, preferably with the texture in the same directory.
#6
new Material(tree)
{
mapTo = "tree";
basetex[0] = "tree";
emissive[0] =false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 256; // anything below this number is not visible and is not written to zbuffer
};
Basically copied and pasted from yours. The material is tree.dds, the model is tree.dts.
So what am I still missing?
06/06/2009 (3:26 pm)
All right, I apologise for continuing to pester you, but I'm still not getting this to work. What I'm not sure of is exactly which pieces of data to plug-in. Here is my script:new Material(tree)
{
mapTo = "tree";
basetex[0] = "tree";
emissive[0] =false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 256; // anything below this number is not visible and is not written to zbuffer
};
Basically copied and pasted from yours. The material is tree.dds, the model is tree.dts.
So what am I still missing?
#7
The only thing I can think of is it might want the exact location of the file in the script.
eg:
basetex[0] = "~/data/shapes/trees/tree.dds";
What all the other things in the script do are explained in the docs.
Post a screenshot of your exact problem.
06/06/2009 (4:52 pm)
I think alpharef only goes up to 255 ... but thats it. As long as you have a working alpha channel, white areas for visible, black areas for transparent.The only thing I can think of is it might want the exact location of the file in the script.
eg:
basetex[0] = "~/data/shapes/trees/tree.dds";
What all the other things in the script do are explained in the docs.
Post a screenshot of your exact problem.
#8
http://www.rickaustinson.com/tree.jpg
This is it's alpha-map:
http://www.rickaustinson.com/treealpha.jpg
And this is the current content of my material.cs file:
new Material(tree)
{
mapTo = "tree";
basetex[0] = ""~/data/shapes/WindColony/tree.dds";
emissive[0] =false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192; // anything below this number is not visible and is not written to zbuffer
};
WindColony being the directory where the tree.dts, tree.dds, and material.cs reside.
06/07/2009 (12:19 pm)
All right, this is the tree in-game:http://www.rickaustinson.com/tree.jpg
This is it's alpha-map:
http://www.rickaustinson.com/treealpha.jpg
And this is the current content of my material.cs file:
new Material(tree)
{
mapTo = "tree";
basetex[0] = ""~/data/shapes/WindColony/tree.dds";
emissive[0] =false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192; // anything below this number is not visible and is not written to zbuffer
};
WindColony being the directory where the tree.dts, tree.dds, and material.cs reside.
#9
Stick it all in a zipfile and upload somewhere and I'll take a look.
06/07/2009 (2:31 pm)
BaffledStick it all in a zipfile and upload somewhere and I'll take a look.
#10
06/07/2009 (2:40 pm)
The whole game or just the dds, dts, and material.cs?
#11
I take it you're using 1.8.1?
Also, what 2D graphics program do you use? (photoshop. gimp, etc)
06/07/2009 (3:06 pm)
lol, just the dds, dts, and material.csI take it you're using 1.8.1?
Also, what 2D graphics program do you use? (photoshop. gimp, etc)
#12
You can download the files in a rar file here:
www.rickaustinson.com/tree.rar
I also through in the max file in case i'm missing soemthing in there, it's max 2009.
06/07/2009 (3:12 pm)
I am using version 1.8.1, my graphics program is Adobe Photoshop 7.0, and the DDSs are created with nVidia's DDS plugin. You can download the files in a rar file here:
www.rickaustinson.com/tree.rar
I also through in the max file in case i'm missing soemthing in there, it's max 2009.
#13
It's always something simple - and something simple is always what I miss!
I just spent aeons ripping all your stuff apart, importing, exporting, fiddling ...
lmao
materials [plural]
06/07/2009 (5:21 pm)
materials.csIt's always something simple - and something simple is always what I miss!
I just spent aeons ripping all your stuff apart, importing, exporting, fiddling ...
lmao
materials [plural]
#14
well, now the material is showing up in the consol log, here's what I get:
ew Material(tree)
{
mapTo = "tree";
basetex[0] = ""~/data/shapes/WindColony/tree.dds";
## ## emissive = false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192; // anything below this number is not visible and is not written to zbuffer
};
>>> Error report complete.
I cannot guess why it's cutting off the n in new material, but the ## represent the line where it's having trouble. I've tried setting a number and removing the line entirely, the texture still isnt' transparent in-game and it's still popping up that error.
06/07/2009 (7:57 pm)
It's always the easy stuff, isn't it? Back when I was studying visual-basic I once spent 15 minutes writing code, then 3 hours figuring out that I had missed a semi-colon. well, now the material is showing up in the consol log, here's what I get:
ew Material(tree)
{
mapTo = "tree";
basetex[0] = ""~/data/shapes/WindColony/tree.dds";
## ## emissive = false;
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192; // anything below this number is not visible and is not written to zbuffer
};
>>> Error report complete.
I cannot guess why it's cutting off the n in new material, but the ## represent the line where it's having trouble. I've tried setting a number and removing the line entirely, the texture still isnt' transparent in-game and it's still popping up that error.
#15
This is what I got working. You'll have to play with the alpharef and BlendOp types to see what you prefer.
Also check to make sure there isn't another image called tree anywhere, I think I found a stock model called tree. There shouldn't be but it's always a good thing to keep the possibility of materials conflicts in mind for the future.
06/07/2009 (8:28 pm)
More easy stuff, you've a double " in basetex.This is what I got working. You'll have to play with the alpharef and BlendOp types to see what you prefer.
new Material(tree)
{
mapTo = "tree";
basetex[0] = "tree";
translucent = true;
translucentBlendOp = LerpAlpha;
translucentZWrite = true;
alphaRef = 192;
};Also check to make sure there isn't another image called tree anywhere, I think I found a stock model called tree. There shouldn't be but it's always a good thing to keep the possibility of materials conflicts in mind for the future.
#16
Also this points to a very obvious example of why I never succeeded at programming: I looked over that line like a dozen times and missed the double " every time!
But it works now. My tree looks bad, but the thing is working and I can model a better tree.
Thank you kindly, this has been a very helpful and educational process.
S&G
Rick
06/07/2009 (9:20 pm)
AHHh! That works! Thank you so very much, you totally rock!Also this points to a very obvious example of why I never succeeded at programming: I looked over that line like a dozen times and missed the double " every time!
But it works now. My tree looks bad, but the thing is working and I can model a better tree.
Thank you kindly, this has been a very helpful and educational process.
S&G
Rick
Associate Steve Acaster
[YorkshireRifles.com]