as you probably guess, i want the green thing to smoothly blend on the ground and not this dark, ugly border. what am i doing wrong? thanks!
🔒 Locked
blend function woes
Advertisement
Original Post
hello, my current blend function is: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); but i am not getting the blend function result i want. here is a screenshot
as you probably guess, i want the green thing to smoothly blend on the ground and not this dark, ugly border. what am i doing wrong? thanks!
as you probably guess, i want the green thing to smoothly blend on the ground and not this dark, ugly border. what am i doing wrong? thanks!
Do you have alpha testing enabled? If so, disable it.
Alpha testing is yet another gate the fragments have to go through before appearing on the screen (depth and stencil are others); It allows fragments to pass through providing they meet the conditions you have set. For example:
That will simply get rid of any fragments that have an alpha that is less than 0.3.
Disabling alpha testing is a simple matter of:
Regards,
DarkProphet
Alpha testing is yet another gate the fragments have to go through before appearing on the screen (depth and stencil are others); It allows fragments to pass through providing they meet the conditions you have set. For example:
glEnable( GL_ALPHA_TEST );glAlphaFunc(GL_GEQUAL, 0.3f);That will simply get rid of any fragments that have an alpha that is less than 0.3.
Disabling alpha testing is a simple matter of:
glDisable(GL_ALPHA_TEST);Regards,
DarkProphet
The alpha tests as far as I know, have no relation to depth sorting.
You depth sort transperant objects in back to front order to get correct blending as the "source" pixel is taken into account when doing blending. The source pixel is the pixel that was there before the current pixel.
You depth sort opaque objects in front to back order to avoid pixel overdraw.
In short, alpha testing has nothing to do with depth sorting. :)
Regards,
DarkProphet
You depth sort transperant objects in back to front order to get correct blending as the "source" pixel is taken into account when doing blending. The source pixel is the pixel that was there before the current pixel.
You depth sort opaque objects in front to back order to avoid pixel overdraw.
In short, alpha testing has nothing to do with depth sorting. :)
Regards,
DarkProphet
Quote:
Original post by Ysaneya
How's your texture set up ?
For the effect you're trying to achieve, i think you should have a constant green RGB color everywhere, and the circular gradient in the alpha. In that case, no dark pixels should appear.
Y.
that might be the problem, unfortunately i am using png textures which dont seem to support an extra alpha channel. :/
Quote:
Original post by ehmdjii
yes, i got that, but when i save it out as png, it is fully green with no alpha channel at all.
When saving make sure you choose 32-bit (if it asks). Most viewer programs don't show an alpha channel but only the RGB component. Open it up again in PS and take a look at the channels, alpha should be there.
Which version of photoshop are you using? With 7 there are some issues with alpha in pngs. If you just do a save as, the alpha information is discarded. Instead you have to use the save for the web option. I think that's on the file menu if I remember right. This brings up a different dialog box which allows you to save it with the alpha data. However, this uses the transparency of the image as alpha instead of an explict channel when generating the alpha channel in the file. This can make working with the alpha data kind of difficult sometimes. I'm not sure if this has been improved in the latest version of photoshop.
In regards to png issues in Phtotoshop you could look at superPNG as a replacement plugin.
youre getting sidetracked the png or phoyoshop etc aint the problem the alpha is obviously working correctly
try this app which shows how opengl blending works set the background color to yellow + the input color to green + play around with the blending modes + input colors alpha value
http://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip
try this app which shows how opengl blending works set the background color to yellow + the input color to green + play around with the blending modes + input colors alpha value
http://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
