Drawing Round Points and Interpolating Images (OpenGL Programming)

Draw near-round, aliased points by enabling point antialiasing, turning blending off, and using an alpha function that passes only fragments with alpha greater than 0.5.

Suppose you have a pair of images (where image can mean a bitmap image or a picture generated using geometry in the usual way), and you want to blend smoothly from one to the other. This can be done easily using the alpha component and appropriate blending operations. Let’s say you want to accomplish the blending in ten steps, where image A is shown in frame 0 and image B is shown in frame 9. The obvious approach is to draw image A with an alpha of (9 – /)/9 and image B with an alpha of i/9 in frame i.

The problem with this method is that both images must be drawn in each frame. A faster approach is to draw image A in frame 0. To get frame 1, blend in 1/9 of image B and 8/9 of what’s there. For frame 2, blend in 1/8 of image B with 7/8 of what’s there. For frame 3, blend in 1/7 of image B with 6/7 of what’s there, and so on. For the last step, you’re just drawing 1/1 of image B blended with 0/1 of what’s left, yielding image B exactly.

tmp73ec-63_thumb


and you blend in B/(9 – i) with (8 – i)/(9 – i) of what’s there, you get

tmp73ec-64_thumb

Next post:

Previous post: