transparency bitmap problem

Blitz3D Forums/Blitz3D Programming/transparency bitmap problem

Osoko(Posted 2006) [#1]
Hi there

I'm using TGA bitmap with alpha channel for displaying trees. I've problems with them, they have transparency OK, but the engine display the trees abnormaly, trees in the front appears behind trees in the back !
What could i Do ?

Thank's


Stevie G(Posted 2006) [#2]
This is a feature of using alpha. The Z-ordering gets disabled so the sprites will be drawn in order based on their distance form camera which sometimes causes issues.

There is an alpha sort routine in the archives which may be of use to you.

Stevie


jfk EO-11110(Posted 2006) [#3]
I would rather suggest not to use Alpha for trees. IMHO you should use DXT3 textures in masked mode. There are plugins to export DDS/DXT for Photoshop and Gimp, even some free standalone converters.

Using the alpha sorting code Stevie mentioned means also speed loss, and you have to include every alphaed mesh in the sorting update function.


Osoko(Posted 2006) [#4]
does blitz load dds ?
Is the problem resolve with these type of texture ?


Dreamora(Posted 2006) [#5]
Yes Blitz 1.97+ loads DDS.

As you only use masking, yes it resolves the issue.

Are you perhaps using "chunking" or some mesh combination algorithm to save surfaces on your trees? (because depth sorting is done against 0,0,0 point of the mesh, not the actual triangle, which causes this kind of error normally - another problem is too high cam ranges as well. min range <= max range / 10000 on 32bit, on 16bit its far smaller!)


Osoko(Posted 2006) [#6]
Well !
I've found a workaround, as I was using big cylindricals planes for aplying "trees group" texture with alpha, i've separate them into smaler pieces. It's works now correctly. I presume as you said that blitz use the center of object to determine the order of display.

But i will look seriously about DDS, does DDS textures uses less Vram ?

Thank's


jfk EO-11110(Posted 2006) [#7]
when you use alpha, the parts of one mesh are not sorted correctly, but randomly. This is a well known and hated "feature". If you split things up into more meshes, it may help.

Masked DDS (DXT3, saved with alpha channel) won't have semitransparent parts, as alpha textures do. But other than masked BMP, PNG etc. DXT3 will draw the outlines using a smooth, round interpolation. It also allows to use a neutral background color on the RGB channel, so texture filtering won't produce black outlines as seen with masked BMP etc.

Yes, DDS/DXT is used compressed in the VRam. AFAIK it uses only as much VRam as the filesize takes. It's perfect for plants, fences, fine structures.