Alpha texture

Blitz3D Forums/Blitz3D Programming/Alpha texture

Bob13(Posted 2005) [#1]
Hi !

I created a .PNG texture with an alpha map. I loaded my object and applied the texture.

...
Tex = loadtexture("test.png",1+2)
EntityTexture Test,Tex
...

Now, where the alpha map is black the object is transparent but also a little bit where the alpha map is white.

Is anybody knows Why ?

I tried with .TGA... .BMP... the same problem !

Thanks for your help.

Bob


jfk EO-11110(Posted 2005) [#2]
If it's only the contours of the white parts (eg. when you use single pixel width lines) then it may have something to do with filtering / mipmapping.

You could try this:
Cleartexturefilters
texturefilter "",1+2
tex=loadtexture("x.png")
cleartexturefilters
texturefilter "",1+8 ; default

But textures without mipmapping may be very slow on some cards. Also make sure your white is really 255,255,255


Banshee(Posted 2005) [#3]
You havn't got entityBlend on have you? Make sure you set the entity to use alpha blending and not leave it set to default colourkey masking.


Bob13(Posted 2005) [#4]
No entityBlend
Just EntityFX Test,1+16 for double side.

I think the .PNG texture is a 24bit and I dont know how to make a 32bit .PNG file...


Matty(Posted 2005) [#5]
Free version of Ultimate Paint can save the alpha channel (32 bit png) in a png file.


Banshee(Posted 2005) [#6]
I may be wrong because I havn't experimented with png transparency but you might want to try adding +32 to your entityFX for alpha blending on.


Gillissie(Posted 2007) [#7]
I have this problem with certain textures too. I can't figure out why some textures work correctly and some cause approximately 50% transparency across the entire texture when loaded with the 2 flag, even in places where the alpha channel is pure white. This is very frustrating!


Gillissie(Posted 2007) [#8]
I have figured out that this only happens when you're loading a texture that doesn't have alpha info (such as a 24-bit png), but you have the 2 flag on. For some reason the alpha pixels seem to default to some middle value instead of pure white, and since the image doesn't provide any alpha info to override it, you get a partially transparent image.

This seems like a bug to me, where the default alpha channel value should be pure white instead of whatever it is now.


jhocking(Posted 2007) [#9]
Okay several points:

1 - It's generally bad form to resurrect a 2 year old thread. That's not a big deal in this case because you had a substantive question to add, but it's still a little confusing.

2 - In your first post you specifically stated "even in places where the alpha channel is pure white" but then in your second post said it only happens when there is no alpha info. If anyone had tried to help you it would have been an incredibly frustrating runaround because of that misinformation. Try to be careful not to tell us facts which aren't true.

3 - Actually as I recall what happens is that Blitz uses the image itself as the alpha channel. Imagine if you desaturated the image to make it greyscale and used that as the alpha channel. I don't recall exactly though so that may be incorrect.

4 - Rather than consider it a bug, you could simply not turn alpha transparency on when there is no alpha channel. Put another way, why are you turning on alpha transparency if you want the image to be fully solid?


Ross C(Posted 2007) [#10]
Your correct on point 3. When masking, it takes a cut off of alpha value at 128. Above that is masked, below that is not masked.


Leon Drake(Posted 2007) [#11]
works fine if i set entityalpha 0.99

usually i use those as an opacity map, do white and then in either gimp or photoshop to the alpha fade that way. then i use it with entityblend with another texture and set the alpha to 0.99 and it looks fine.


Gillissie(Posted 2007) [#12]
@jhocking:
1 - I didn't see a resolution, so I considered it still open, regardless of age. Now it has a resolution and I promise not to bring it back in a couple years. :)

2 - This was part of the reason for my quick follow-up post. At first I thought I was using a 32-bit image with full alpha because I specified to save the transparency from Photoshop. Apparently Photoshop ignores that request when it doesn't detect any transparency, and saves it as 24 bit for you (gotta love automatic crap like that). When I realized that my image was actually saved as 24-bit, I posted the followup.

3 - It doesn't really matter at this point, since I figured out the workaround.

4- Well, it is a bug even if there is a workaround. But the reason I was loading with the 2 flag unconditionally is because the LoadTexture function was inside a function that may or may not load an image with alpha transparency. I just used the 2 flag to cover all bases. Now that I know that is causing the issue, I added an argument to the function to specify whether or not to use the 2 flag.


John Blackledge(Posted 2007) [#13]
What does it matter if you bring an old thread back?
It's still as relevant as ever, and I still read every word to fill in the gaps in my own knowledge.
Thanks, Todd.


jhocking(Posted 2007) [#14]
It's not a bug because that behavior is done on purpose (ie. mark meant for it to use the image as the alpha when there is no alpha channel.) And it's not a workaround to create an alpha channel for using with alpha transparency, that's just how alpha transparency works. As in, it's not a workaround to do what you are supposed to do. A workaround is when you figure out a way to accomplish something even though the correct method is broken.

Not important, just semantics that were needling me.


Gillissie(Posted 2007) [#15]
Regardless, I don't remember seeing that "feature" documented, so the clarification here was worth it.