Alpha Transparent Textures

Blitz3D Forums/Blitz3D Beginners Area/Alpha Transparent Textures

YellBellzDotCom(Posted 2008) [#1]
I am trying to make a tree with alpha transparent texturing for the leaves ilo of masked textures. The problem is, everytime I use an alpha texture, parts of the model are rendered on top of other parts like a zorder issue. Ive created a small demo to show this problem. Does anyone have any ideas whats happening with my alpha texture?

Download the zip file here, its 835kb
http://dodownload.filefront.com/9489881//1532576500828fdb31f71838a901ef86d5322449fe5b0b3eb4710af0fdc69be267933ba60ccc7278

Thanks!


Dreamora(Posted 2008) [#2]
If you use 2 distinct textures, this shouldn't be a problem. If you UV map 1 textures, one with alpha, one without onto the same model it will break as the whole thing is rendered in a single go.


YellBellzDotCom(Posted 2008) [#3]
In the zip file for the Maple Alpha.b3d model it uses 2 textures. 1 is the bark for the trunk which doesnt have an alpha layer and the other is a texture for the leaves which has an alpha layer to make the background invisible.

So is this the wrong way to set it up? I dont know of any other way.

Thanks.


YellBellzDotCom(Posted 2008) [#4]
I broke the model up into 2 seperate models, the trunk and the leaves. I then loaded them into blitz and it rendered just like the single model, same problem with the alpha textured leaves.


SLotman(Posted 2008) [#5]
Unless you manually z-order everything, change it to use masks intead of alpha or z-ordering is implemented on B3D, this will never be fixed, no matter how you model it.


Dreamora(Posted 2008) [#6]
If it is multiple "plains" of alpha each behind the other within a single mesh, then yes, splitting up won't help, you will need to implement a foliage system to handle this kind of alpha as SLotman says


Ross C(Posted 2008) [#7]
Have you tried mask textures? Change the mask colour of the texture to something close to the actual colour, so you don't get the awful black outline thing.


YellBellzDotCom(Posted 2008) [#8]
Actually thats the reason I was trying the alpha texture. My masked texture looks great on all but the first tree I loaded which has the black border happening. I didnt know how to stop it from doing that and some people recommended the alpha texture path. But from what Im reading here, I cannot fix the alpha texture problem on my model so Ill take a look at your masked texture idea, it seems like a good idea.

Thanks.


Ross C(Posted 2008) [#9]
Skidracer produced some great code for changing the mask colour to the nearest colour of the non masked pixels. I have some code in the archives for changing the mask colour of a texture to what ever colour you input too. Click on my name, then code archive entries.

I think Skid's might be better code though.


Dreamora(Posted 2008) [#10]
that is great but does not interest textures.
Textures always have black as mask color, you can not alter it.


Ross C(Posted 2008) [#11]
No they don't :o) The maks of a texture is determined by the alpha values of the texture. Alpha values above or equal to 128 are masked pixels, values below 128 are non masked, therefore, it doesn't matter which colour the pixels/texels are.


jfk EO-11110(Posted 2008) [#12]
using no alpha channel is a NONO. THe only mask thing that is looking really good is:

use transparency for the background (eg. in Photoshop or THe Gimp). Then clone the layer of your masked texture and move this layer under the actual texture layer. then set the clones transparency to about 2%. Then "blur more" the clone. Then (attention) export as DDS DXT5 (i think 5) Masked(!) texture, using the DDS export plugin (there are plugins, just look around).

Here's a fence using a 512*512 pixel masked DDS texture. As you can see, the outline was vectorized and is smoothed, contrary to masked BMP that would be extremly blocky (stairs).


Note also: no black borders, due to the blurred 2% clone .(Thanks to the one who gave me this hint, guess it was Fredborg, was it?)


YellBellzDotCom(Posted 2008) [#13]
Well, I tried to follow those instructions, but I still get all messed up. Heres a screenie of my photoshop file...



I selected the leaves in the Masked Texture layer, went to the channgels tab and created a new layer from selection. This created the alpha layer(?). 1 problem is, when I tried to save to DDS DXT5, I would get an error saying "too many channels 5".

I Have created alpha images and loaded them into blitz3d, just to check the alpha transparency and they worked fine. It was just that trying to use that Image as a texture and it would cause a zorder situation on the model.

Thanks for the help


jfk EO-11110(Posted 2008) [#14]
Don't use an alpha channel in photoshop. Instead use unpainted areas (where checkerboard shines trough). The black parts must be deleted, of course, You may use the "select color" tool, but I'm afraid this texture already is antialiased to black. BTW I did this texture (edit: that's no problem, but I made it before blitz supported DDS, so the background is black). Probably you better start with a new texture, that is big enough for proper contour selection.

Sorted alpha would be cool, although you should use masks if possible in the first place, because of performence issues as well as the discussed z-order problems.

You should avoid especially alpha objects with multiple parts, because the zorder problem only happens whithin the same surface. If for example your tree is using multiple meshes (with unique surfaces) as the limbs then z-order should work.


YellBellzDotCom(Posted 2008) [#15]
Thanks for the info there I do appreciate it. You are right, this your texture. It came with the Blitz3d Tree creator and it was perfect for placeholders in my map. I originally used masked textures on my Ted created terrain and they all looked great except for the first instance of the tree I placed. It had the black border around the leaves. If I loaded the trees manually with code, all the trees showed up perfectly. I never could figure out the dilemma so I moved on.

Thanks for your help, I really appreciate it.


vinnicius(Posted 2014) [#16]
How can i export the 3ds model (the tree with leaves etc) to blitz3d? I can see the leaves correctly on 3d studio max, but when I load into blitz3d it does not work (the transparency became black).

WHen i use sprites the texture works well (using the mask etc)