|
From: James S. <jsi...@li...> - 2001-04-03 16:29:35
|
Okay I see their is some confusion on what anti-aliasing can and can't do. Warning this email is long. >I assume the Transp is for Alpha blending. transp is the fourth color component. What you can do with the alpha value depends on the blend factors. Durning blending color values of incoming fragments (source) are combines in some way with the color values of the corresponding currently stored pixel (destination) in a 2 stage process. First you state how to compute the source and destination factors. These factors are RGBA quadruplets which are multipled by each component of the RGBA values in the source and destination. Then the two set of RGBA quadruplets are added together. Lets show this mathimatically. The source blending factor is represented by: (Sr,Sg,Sb,Sa) The destination blending factor is represented by: (Dr, Dg, Db, Da) Now the color of the source is represented by : (Rs, Gs, Bs, As) Color of the destination is represented by: (Rd, Gd, Bd, Ad) So the final blend is : (RsSr + RdDr, GsSg + GdDg, BsSb + BdDd, AsSa + AdDa) Now the blending factors could be alot of things. The most common which are defined by OpenGL are: zero: Source or destination (0,0,0,0) one: Source or destination (1,1,1,1) destination color: Source (Rd, Gd, Bd, Ad) source color: destination (Rs, Gs, Bs, As) 1-destination color: source (1,1,1,1)-(Rd,Gd,Bd,Ad) 1-source color: destination (1,1,1,1)-(Rs,Gs,Bs,As) source alpha: source or destination (As, As, As, As) 1-source alpha: " " (1,1,1,1)-(As, As, As, As) destination alpha: " " (Ad, Ad, Ad, Ad) 1-destination alpha: " " (1,1,1,1)-(Ad, Ad, Ad, Ad) alph saturate: source (f,f,f,1);f=min(As, 1-Ad) What does this all mean? Well you can do several effects using the right blend factors. Some are: One way to draw a picture composed of half of one image and half of another equally blended is have teh source factor equal to one and the destination factor equal to zero and draw the first image. Then set the source factor to source alpha and destination factor to 1 - source alpha. Now draw the second image with alpha set to 0.5. This is the common example of a blending operation. Second example is how to blend three objects together. Set the destination factor to one and the source factor to source alpha. Draw all 3 images with alpha set to 1/3. Here where the objects don't overlap the brightness will be 1/3 of it orginal. Where they do they will be 100% of brigtness. The 3rd example is the paint brush example. Say you want to gradually add a color. Here we draw the image with a alpha value of say 10 percent and use source alpha and destination alpha minus one. Just keep appliing the brush. Here is a good example of where you wnat to use each alpha value in each pixel if you want to get a gradient of a color change to the picture. The fourth one is creating a color filter. This allows one to modulate each color componet. Say you want to filter out 20% of the red out of a image. You set the source factor to destination color or destination color minus one and source color or one minus source color for the destination factor. So now if multiple the red compenent by %80 you will effectly block out 20% of the red of teh object. Fifth technique. The classic example of translucent. Say you want to draw three objects in front of a solid color wall. Farthest object transmits 80%, next closest object transmits 40% and the closest transmit 90 %. First draw the wall. Next change the source factor to source alpha and teh destination factor to 1-source alpha. Draw each object with alpha values to what you want (.8, .4, .9). The use of nonrectangular raster images (what Scott was talking about). Also know as the alpha test. This technique is used to draw "3D" objects with 2D planes. Image you had 2 planes that are 90 degrees to each other. On each plane you have a image of a tree. Here you assign alpha 0 to the invisible parts and 1 to the visible parts on each plane. Now the leaves in one planes are seen behind the transparent parts in the plane closer to you giving a three appearance. Othe uses which I will not go into. Anitaliasing fonts and images. Alpha blending is used for radiosity and ray tracing algorthims to do shortcuts to speed up rendering. You can do composting and matting techniques with fully rendered objects. Blah blah. SO I hope that clears how alpha values are really used. For those of you that play with OpenGL and openGL drivers gives try these techniques out. They are pretty neat. MS: (n) 1. A debilitating and surprisingly widespread affliction that renders the sufferer barely able to perform the simplest task. 2. A disease. James Simmons [jsi...@li...] ____/| fbdev/console/gfx developer \ o.O| http://www.linux-fbdev.org =(_)= http://linuxgfx.sourceforge.net U http://linuxconsole.sourceforge.net |