Alpha Channel for Sketchup models

Blitz3D Forums/Blitz3D Beginners Area/Alpha Channel for Sketchup models

simcenter(Posted 2006) [#1]
I recently used Sketchup to create a tree-scape (just a whole bunch of trees). In sketchup I used Bitmap textures with alpha channels for the trees. So each tree is basically a plane with an alpha bitmap applied to it, so that in Sketchup you only see the tree.

So, I export that tree layer out as one .3ds file. I import it into Blitz3D, but the alpha channel doesn't automatically work. I've been searching all over for some alpha help but have given up searching the codes and archives.

I guess the problem is that within this one 3ds file, there are three different bitmap textures...so I don't think I can just apply a texture to the mesh created from the 3ds...

Am I the only one baffled by this conundrum?


b32(Posted 2006) [#2]
You could use TextureFilter. It searches for a certain word in the filename of any texture that is loaded and then applies the specified filters to that texture.
Ie: Texturefilter "_masked", 4
will search for the term "_masked" in texture filenames and then apply flag 4 (=masked)


simcenter(Posted 2006) [#3]
Thanks b32, but so far the "texturefilter" command isn't helping at all. I think I'm using it properly, according to the help content, but I still keep seeing the black of the alpha channel.

I've used the mask function before when loading an image from a jpg, when I didn't want to see the black pixels, but for some reason it's not working when the texture is embedded with the 3ds file...


b32(Posted 2006) [#4]
I've had difficulties too with using alpha. Have you tried setting EntityFX 32 ? And have you tested the textures on standard shapes (createcube) ? That way you can test if the standard way of appying the texture works:

In this, I've used a .png file, because it can hold alpha data. If you can apply the texture onto the mesh with maintaining the alpha, you can use:
GetSurface(), GetSurfaceBrush(), GetBrushTexture() and finally GetTextureName$() to find out what texture is applied to what surface. Then you can reload the same texture and re-apply it to the mesh.
If you can't solve this, try posting one of the models with textures.


Stevie G(Posted 2006) [#5]
simcenter,

I don't get how you can apply alpha channels to a Bmp. Bmp's don't hold alpha information so it'll be lost as soon as it's loaded with the model. Entityfx 32 will have no bearing on the texture as it relates to vertex alpha only.

The simplest way is to save the texture as a .png which does support alpha. I've never used SketchUp so no idea if this is even possible.

If that still doesn't work then one hack would be to getbrushtexture as above and loop through all the pixels in the texture setting the alpha as you go ... e.g. if color doesn't equal 0 then alpha = 1.0 else alpha = 0.0.

Stevie


b32(Posted 2006) [#6]
Ah, so that is what EntityFX 32 is for .. it is just one of those things I try when stuff doesn't work. :)


simcenter(Posted 2006) [#7]
Okay, so now it seems as if I figured out how to use TextureFilter, at least a little. However there are some more problems that maybe someone knows about:

When I use the code:

trees=LoadMesh("models\trees\trees.3ds")
PositionEntity trees,0,0,0
TextureFilter "", 6


I see this image:


At first, I thought that the Texturefilter didn't work...however, I then used the following code:

trees=LoadMesh("models\trees\trees.3ds")
PositionEntity trees,0,0,0
TextureFilter "", 6

trees2=LoadMesh("models\trees\trees.3ds")
PositionEntity trees2,0,0,0
TextureFilter "", 6
FlipMesh trees2


..and then, I saw this:



Which made be believe that the code was working...however, walking around the landscape a little more, I saw that the trees were actually coming in as the following:



So, it seems as if the Texture filter only works for the flipped version of the "trees.3ds" file...Although I also found that if I load only one entity from the 3ds and flip it, the alpha doesn't work. I can only "see through" the flipped version if there is a non flipped version as well...

The images are the same if I use Texture Filter (2), (4) or (6)...

(I also tried the GetBrushTexture() to no avail, although I could have been doing it wrong. I think I'm getting closer with the TextureFilter.)


simcenter(Posted 2006) [#8]
Side note: I now realize that this is not an alpha issue, its a masking issue.

I don't know that much about image formats, but it seems as if bmp can now store alpha channels. the newer Photoshops seem to be able to open them up.

Sketchup can load many types of image files as textures, but when exporting to 3ds, it will only export jpg and bmp, thus all png or rgba will be turned into bmp or jpg automatically. This is why I'm trying to deal with a masking as opposed to jpb, and also why I'm trying to figure out if the alpha channel from a bmp is doable in Blitz.

But for now, the TextureFilter is still giving me problems as displayed above.


simcenter(Posted 2006) [#9]
This whole topic should probably be erased, since I just found the answer here

Evidently I wasn't understanding where to put the TextureFilter portion of the code. Instead of putting it right before loading the 3ds file, I was putting it directly after...

I realize I'm still making these horrible simple mistakes, thanks for all who helped me.