Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Read TGA Alpha Channel  (Read 1193 times)
Soganatsu
Customers
Community Member
*****
Posts: 67


« on: November 08, 2010, 03:46:56 PM »

Hey guys, it's me again ^^

After a long period of lazyness I've finally managed to get Diffuse, Normal and Specular working. Same goes for an alpha channel. Here comes the issue though: This is how I'm reading my alpha values from the diffuse texture's alpha channel in my shader:

Code:
float4 texDiffuse = tex2D(sampDiffuse, IN.texCoord);

...

alpha = texDiffuse.a;

...

return float4(color, alpha);

...

pass P
{
AlphaBlendEnable = true;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;

VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}

This is the texture I'm using:

http://www.mediafire.com/?9y0c0f158gdc0a8

And here's the texture's RGB and Alpha channels:



Now everytime I read in my alpha channel all I get is pure white for every pixel.
Is there anything I should test to make sure the texture actually loads correctly?
I've tried loading the alpha channel as a whole seperate texture. Using that texture, I can easily grab the channel using:

Code:
alpha = texSeperate.r; //(Or g, or b, but NOT a)

which also displays correctly, but I'd still like to use the alpha channel of my diffuse texture for alpha purposes, so I can discard that extra texture lookup.

Would be really nice if anyone could help me out Wink

Greets,
Philipp
Logged
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #1 on: November 08, 2010, 04:45:34 PM »

When you call LoadTexture, do you set LoadAlpha to true?
If you dont, TV will not load the alpha channel.
Also, I recommend using DDS textures.
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
Soganatsu
Customers
Community Member
*****
Posts: 67


« Reply #2 on: November 09, 2010, 07:32:36 AM »

I don't see a LoadAlpha boolean anywhere on the LoadTexture Function.
All I see is the ColorKey And FilterAndStretch.

Do you mean I have to load the alpha texture seperately using LoadAlphaTexture and apply it to the original texture?

Greets,
Philipp
Logged
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #3 on: November 09, 2010, 08:47:52 AM »

Oh that's right, I mixed it up with some other command, sorry (I was thinking of CreateTexture HasAlpha flag).

Come to think of it, i'm kind of sure TGA alpha channel isn't supported. I have heard of people using PNG and DDS. I myself use DDS and have never had problems. You can get DDS exporters for photoshop and probably converters somewhere online. Then just save to the A8R8G8B8 format and it should work (if you need 8bit alpha).
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
Soganatsu
Customers
Community Member
*****
Posts: 67


« Reply #4 on: November 09, 2010, 10:33:04 AM »

I've already tried the Nvidia DDS toolset and converted the TGA to DDS, still no luck.
Logged
Toaster
Community Member
*
Posts: 378


WWW
« Reply #5 on: November 09, 2010, 02:33:08 PM »

use TVCOLORKEY.ALPHA. or something lol

-Toaster
Logged

Visit my site at: Unknown Abstraction
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #6 on: November 10, 2010, 06:58:51 AM »

Well, I've always used DDS and the .a channel was always read properly by the shader. I'm not sure what could be causing your problem.

Step backwards and try making a simple shader to convert the texture's .a channel to .rgb and output it as 0-1 and see if it shows then.

Or maybe it's some mesh blending mode issue that's causing you to not see it. Could be anything, can't say without more info.
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks