This topic is now archived and is closed to further replies.

alpha blending and z-buffering

This topic is 5012 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

alpha blending is the blending of pixels onto each other based on their alpha channel...what that means is

if pixels have an alpha chanel that means that besides just having RGB components they also have an A (for alpha componenet). so they each pixel with an alpha channel has ARGB. just as say R can have a value between 0-255 which says how much Red is in that pixel. the A can have a value between 0-255 which says how transperent it is. --- alpha channel controls transpenrency. 0 being totally transperent and 255 being totally opaque.

So if you had an image each pixel in that image woudl have an RGB and an A component in them. If you put that pixture on top of another pixture they would (blend) meaning that the pixels color on top would be added (or whatever) to the pixels on the bottom. the alpha chanel controls how much of the top color gets blended to the bottom color. If the alpha channel for a given pixel was 255 it would completly replace the bottom color. if it was 0 the bottom color would completly shine though. if it was in between the resulting color would be somethign in between the 2.

now Z buffering is completly diffrent, no relation to alpha blending.

Z buffering eliminates the problem with the painters algorythem which is typically used to render a 3d scene (drawing everything from front to back). basicly what z buffering does is, every pixel that is drawin to the screen (or back buffer) is saved with a Z value. So in this case the pixels on the screen have an RGBZ where the Z is how far the pixel is away from the camera. So pixels drawin from objects far away from the camera have a larger Z value than pixels close to the camera....what does this do? before a pixel is drawin to the screen, the Z component of that pixel is checked. And only if it is closer to the camera than the previous pixel that was there, will it be drawn.

hope that helps, and actually there is a bit of a relation between Z buffering and Alpha blending. and that is if you are doing alpha blending in a scene. you must be sure to render your scene front to back, b/c it can only blend with pixels that are already in the Z buffer. B/c once a new pixel is added to the z buffer the old one is trashed. so there is no way it can go back and figure out what color to beld it with.

if your using directx read the sdk! both of these concepts are explained thurougly in there. if your using opengl...i dont know, never used it.

take care

Share this post

Link to post
Share on other sites
thankyou very much for guidence .I have so much problem .I found on google but cannot find thankx again for your help and guidence.

Share this post

Link to post
Share on other sites