Sign in to follow this  

Additive Blending (Premultiplied Alpha)

This topic is 3785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to get blending working as described in TomF's blog ( http://home.comcast.net/~tom_forsyth/blog.wiki.html, search premultiplied alpha ). First I had alpha blending... srcFactor = _SRC_ALPHA dstFactor = _ONE_MINUS_SRC_ALPHA textureRGB = all white textureA = white displays image, black is removed vertexRGB = image is this color where textureA is white vertexA = start 1.0 -> 0.0 end (fading to nothing over time) ...resulting in fade from initial color to final color, and alpha from solid at start to clear at death then I changed to additive blending... srcFactor = _SRC_ALPHA dstFactor = _ONE textureRGB = all white textureA = white displays image, black is removed vertexRGB = image is this color where textureA is white vertexA = start 1.0 -> 0.0 end (fading to nothing over time) ...resulting in nice blend where overlaps occur, and also fading to clear at death, but vertexRGB is not determining the color, all you get is white Now if I understand correctly "premultiplied alpha" is both of these? From the article I gather from the second paragraph srcFactor = _ONE dstFactor = _ONE_MINUS_SRC_ALPHA ok, but what happens to the following in this case? do they require a change, Im getting the feeling they do. textureRGB = ? all white textureA = ? white displays image, black is removed vertexRGB = ? image is this color where textureA is white vertexA = ? start 1.0 -> 0.0 end (fading to nothing over time) Other articles, have mentioned changes such as _ONE|_ONE to do additive with no alpha component in vertex or texture, white in texture RGB where vertex RGB is to be displayed and black in texture RGB where nothing is to be displayed. Ive tried this and get the same white, not the vertex color Im trying to get. Im trying to achieve what is mentioned in the last paragraph of TomF's premultiplied article, but the creating the texture and trying to fade to clear properly is messing me up I think.

Share this post


Link to post
Share on other sites
Quote:
Original post by NumberXaero
Now if I understand correctly "premultiplied alpha" is both of these? From the article I gather from the second paragraph

srcFactor = _ONE
dstFactor = _ONE_MINUS_SRC_ALPHA

ok, but what happens to the following in this case? do they require a change, Im getting the feeling they do.

textureRGB = ? all white
textureA = ? white displays image, black is removed
vertexRGB = ? image is this color where textureA is white
vertexA = ? start 1.0 -> 0.0 end (fading to nothing over time)


Yes, you have to premultiply your RGB part with your A part :-) That means you have to modify your texture with a paint program (gimp/photoshop).
Your test case is just a little bit too simple, it might be somewhat confusing, but your result should look like this:

textureRGB = textureA, because white (1.0) multiplied with your alpha value is the same as your alpha value
textureA = unmodified
vertexRGB = ??, dont understand the vertex part here, do you mean vertex or pixel ?
vertexA = ..

--
Ashaman

Share this post


Link to post
Share on other sites
With the vertexRGB, vertexA, I meant controlling the color and transparency of the final image using the vertex rgba, and I was wondering if that changes when using src = ONE, dst = ONE_MINUS_SRC_ALPHA. In other words should I start painting into that white textures rgb channels, that I had previously left white when alpha blending.
Thus far Ive been using, plain white texture, containing white in the alpha where I want the image, black else where.
What I was getting at is how the following should be prepared

// Renderstates (from the article)
srcFactor = _ONE
dstFactor = _ONE_MINUS_SRC_ALPHA

now what affect does this have on images that were created and used with alpha blending in mind, and the attributes below

// Texture channels (rgb usually painted as one, a separately worked on)
textureRGB = ? all white (I think the alpha channel needs to be copied here?)
textureA = ? white displays image, black is removed

// Vertex Data (rgb determines textures color, alpha the transparency level)
vertexRGB = ? image is this color where textureA is white
vertexA = ? start 1.0 -> 0.0 end (fading to nothing over time)

With the goal to be using src = _ONE, dst = _ONE_MINUS_SRC_ALPHA, and have a texture mapped image overall color be controlled by vertex rgb, and how transparent it is be controlled by vertex alpha.
Currently Im getting results like fading from clear to solid (would like the other way around), the whole texture being displayed (not just the intended shape), black color only (vertex color seemingly ignored), and poorly blended results (individual polygon pieces are distinguishable in a group).
The last paragraph in the article sums up why Im trying this. Thanks for any help.

Edit:
After rereading your post, do you mean I have to manually apply the alpha channel to the rgb channels somehow?

[Edited by - NumberXaero on August 3, 2007 3:10:48 PM]

Share this post


Link to post
Share on other sites

This topic is 3785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this