What's new

OpenGL Texture Transparency (hmmm)

Cyberman

Moderator
Moderator
All right I have potentially a bit of a problem here. I need to apply
textures to some models. What's my problem you ask? Well..

I have to provide transparency for the textures.

Fortunately I don't believe any blending is needed for this part just
texture tranparency in the right places. The caveat is some of the
texture values are set transparent that aren't black.



What am I doing? Well the playstation does the following operations on a texture.



if (bit15) is set on the color

if the color value 0x8000 (IE the transparency bit set and the rest 0) the color is solid black (no transparency).

else the color is blended with what's on the screen ( 1 of 4 modes)

else

if the color value is 0 then it's transparent and invisible

else it's an opaque color



The models I'm rendering were made for the playstation so I have to
convert the textures into something that can be used in openGL.



I was thinking of using

Code:
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I don't want to use DECAL mode because it will mess up textures in general.



Code:
glEnable(GL_ALPHA_TEST);

glAlphaFunc(GL_GREATER, 0);
Is another option since the alpha is either on or off and I am not sure
if the textures are blended into the model. (not likely).



Cyb - suggestions welcome..
 

BGNG

New member
Use GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA, but keep the opacity at 1 via the glDrawColor function. If you use a 32-bit RGBA texture, the alpha will be applied accordingly. Alls you gotta do is load an RGB image at startup and scan each pixel for the ones you want to be transparent, then set their alpha channel to 0.
 
OP
Cyberman

Cyberman

Moderator
Moderator
I frequent Nehe a lot, unfortunately I believe I have an issue of the chicken and the egg. Because of the way the OGL context initializes under windows, the texture I don't think gets initialized when it should be so this error comes up. Perhaps I should make a few changes to the code. What a PITA.

Cyb
 

bjz

New member
I read through your post twice yet I was unable to find an actual question in there. :p Maybe I'm blind, but I doubt it. What exactly is the problem your having?
 
OP
Cyberman

Cyberman

Moderator
Moderator
My question is how to perform transparency making part of a texture invisible. I can't really see my results currently because of the way windows fires crap off. (UGH) it's like semi random in event order.

I have a list of C++ objects that are called to render the skeleton object (as FF7 uses a simple form of skeleton animation).
So I have a GSkeleton object that has a collection of bones (23 for cloud).
The textures are objects that belong to the skeleton (that's a 'no doh' but I have to say everything I suppose). Interally they are bitmaps and gl Texture objects. The bitmaps are generated by doing a pass through all the (damned) textured polygons. Textures are stored as GTexture. Vertices etc are stored per bone (not for the whole model). Bone lengths are applied to the object relating (or non object in relation to joints). A translation then rotation set is needed for each part. GBone is the bone object. GTriangle colored vertex triangle GQuad .. ditto for a quadric. GTTriangle is a textured triangle.. etc. It's all neat in C++.

Here is where I have my problems. Firstly I have no image (hmm) however that will be resolved soon LOL. Secondly and my primary problem has been all textures appeared black. This is good in that it ment I was pasting a texture out there. Bad that it wasn't the right texture object or something else. That being said I was wondering what mode I can make parts of the texture COMPLETELY transparent. IE invisible. There is no partial transparency with FF7's objects save one. So I would like to be sure I'm doing the transparency right :D

Cyb
 

bjz

New member
The easiest way and probobly the best in ogl is alpha testing as you already know from lookingat your first post. Some things to check but probobly wont make a differance.

- Double check your texture coordinates on your model.
- If your using lighting dont forget to calculate and apply your normals, which could also make everything appear black.
- Now if all else fails step through in the debugger and make sure your textures are all actually getting loaded.

Sorry I cant be of more assistance, feel free to give me more info on irc as you get it and I'll do my best to try and help you.
 

Top