Sprite Antialiasing Technique

Started by
5 comments, last by FuzzyBunny 21 years, 4 months ago
This is not a question, but rather an idea I came across. I develop simple games that are mostly 2D, but I use D3D to make some cool effects like rotating, scaling, color changing, ect... I came up with a way to improve my sprite appearance without sacrifysing any performance at all. This might not be the best solution, or the most original, but I thought of it, and havent seen it mensioned anywhere before. I''m sure alot of you have done this, but not that many people develop 2D sprite based games yousing 3D. For me going full 3D is a little too complex and just love the feel of simple 2D games, which can have more graphics detail by using pre-rendered sprites, objects, backgrounds. There is a huge improvement by using 3D to render 2D, like texture filtering, but that blurs your texture, and you still have the jaggies like all the old 2D games. So this is what I''ve done: When I load my sprite texture,I use a colorkey to make some parts completely transparent, then apply a blur to the alpha channel only. Basically this does not change the color information of the texture, but it makes the edges of the sprite blend in with the background, making an antialiased effect. When using hardware 3D, this comes at no price at all, but makes all my sprites look much better and smoother. Any thoughts?
Advertisement
Hmm, let me see. If it works, use it.
It does work. I just wanted to share my idea with everyone who could have use for it. And I guess your textures need to be in ARGB format to support the alpha blending. Other than that, this works very well.
sorry FuzzyBunny, but this is an old technique. talk to any graphics artist who uses PS or PSP or Gimp or any that use layers. we were using this 5 years ago with GDI-based games via DIB blits. and yeah, it works great with D3D, although don''t forget to look at the caps of the card. the card has to support alpha-blending before you can use this technique.
How do you apply a blur to the alpha channel? Sorry if this is a stupid question...
You take each pixel and change its value so that it is based on an average of the pixels around it as well as its initial value.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
Yeah, you have to get access to your texture pixel data, then you can manipulate the pixels, which contain the RGB and A (alpha) information. Loop through all the pixels in the sprite, and for each pixel, you take an average of 9 pixel matrix and set that to the current pixel (alpha only). That''s the most basic blurring algorythm. You can use 3x3, 5x5, or any other matrix size you want, the bigger the matrix, the more it will blur. You can apply this blur multiple times to achieve even smoother sprite edge blending.

This topic is closed to new replies.

Advertisement