Skip to main content
GameDev.net gamedev.net
🔒 Locked

alpha_test+blend=problem

Started by frca Sep 15, 2005 at 4:35 PM 0 replies 1.9k views
Original Post
frca
frca
Hi, i got one problem: I got a texture in GL_RGBA format. Alpha takes 8 bits, i. e. the texture is variously transparent. I make some polygon with that. Then i use Alpha Test like glAlphaFunc(GL_GREATER, 0.5). The polygon goes partly away. Then i would like to render the rest of it transparently (transparency is somehow set, e. g. glColor4d). The problem is i need every pixel to be transparent the same, but it doesn't work like that, because it computes transparency both with that alpha set by glColor4d and the alpha bit of the pixel in the texture. Thanks for your suggestions, typek PS: I got some replies from another forums that it's only possible using shaders. It would be nice to get solution working even at older cards. Thanks
Enigma
Enigma
Let me see if I understand you. You want to render a textured polygon. The texture has alpha and you want to cull fragments based on that alpha. You then want to ignore the alpha of the fragments that were not culled and blend them all using a constant blend factor? If so then provided your target cards support the imaging subset you should be able to do it by using a constant blend colour, i.e.:
glEnable(GL_TEXTURE_2D);glEnable(GL_ALPHA_TEST);glAlphaFunc(GL_GREATER, 0.5);glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);glEnable(GL_BLEND);glBlendColor(blendFactor, blendFactor, blendFactor, blendFactor);// draw polygon

Barring that you could try destination blending (glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);) but you'd have to write your blend factor to the frame buffer then.

Enigma

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.