transparent

Started by
16 comments, last by Kalidor 17 years, 6 months ago
i'm having some trouble again with my transparency... my sprites are being rendered with depth test and depth mask on and blending turned on with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); as the blending function. BUT, in places where my texture has alpha of 0, it doesn't show the sprite behind it, it shows black, as if the color is black with alpha of 255. what's wrong?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Advertisement
Are you drawing your sprites in the correct order?

Also, I believe that the correct term is transcluency, not transparency. A transparent object is invisible =)

To make it is hell. To fail is divine.

the objects don't need to be drawn in order, that's what the depth test is. and when i say transparent, i mean part of my sprite is transparent (alpha 0) and a lot is opaque (alpha 255), the part that's 0 is not showing the sprite behind it, it's showing up black
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
When you load it, are you loading it as GL_RGBA?

Also, try rendering it with the depth mask disabled.
With alphablending the drawing order DOES matter...

Have you set the correct vertex color before the texture draw eg. glColor(255,255,255) ?
sounds like you need alpha testing, not blending:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);

note that with blending enabled, you might have blurry edges where the draw order *does* matter, even with alpha values of only 0 and 255. i think openGL does this to make it look smoother.
---Current pet project: ProjectM
well that fixed it, is there a way to disable the "smooth" thing? because it's like I see a fine line of black pixels at the edge of my texture that has the alpha test
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
if i can't do that, how ELSE am i supposed to get sprites to look correctly?? i need blending, i obviously need alpha testing, and i need depth testing and mask.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Try moving your texture coordinates slightly towards the initerior of your texture (i.e. 0.001 instead of 0.0 and 0.999 instead of 1.0). Due to sampling inaccuracies there might be a "seam" at the border when using exact coordinates.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
i'll try moving it a texel in towards the center
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML

This topic is closed to new replies.

Advertisement