Premultiplied alpha content processor

As mentioned in my previous post, a Content Processor that converts textures into premultiplied alpha format: using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content.Pipeline; using Microsoft.Xna.Framework.Content.Pipeline.Graphics; using Microsoft.Xna.Framework.Content.Pipeline.Processors; namespace PremultipliedAlpha { [ContentProcessor] class PremultipliedAlphaTextureProcessor : TextureProcessor { public override TextureContent Process(TextureContent input, ContentProcessorContext context) { input.ConvertBitmapType(typeof(PixelBitmapContent<Color>)); foreach (MipmapChain mipChain in input.Faces) { foreach (PixelBitmapContent<Color> bitmap in mipChain) { for…

7

Premultiplied alpha in XNA Game Studio

It is possible to use premultiplied alpha with XNA Game Studio, but the bad news is we don’t do much to help you with it. Why not? Yeah.  Our bad.  In fact one of my biggest regrets about the design of the XNA Framework is that we didn’t do more to make this easier! To…

4

Premultiplied alpha and image composition

From Wikipedia: "Alpha compositing is the process of combining an image with a background to create the appearance of partial transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image in a process called compositing."   Example I am making…

8

Premultiplied alpha

Remember when you first figured out Santa Claus wasn’t real? The growing doubt, tempered by the fact that all your friends believed in him, and surely they can’t ALL be wrong, then the gradual realization that everybody was in fact wrong… Well, I’ve got another one for you: the way most people do alpha blending…

14

Texture filtering: alpha cutouts

Consider a cutout texture that contains a solid shape surrounded by transparency. Let’s say this is a tree, although it could equally well be a cat or an overweight Italian plumber. Our tree is opaque and colored green: tree  =  (0, 255, 0, 255) The surrounding pixels are transparent: border  =  (0, 0, 0, 0)…

2