<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx</link><description>As of Game Studio 4.0, the default alpha blending mode is now premultiplied rather than interpolative. &amp;#160; Why? I was fed up of repeating this conversation: Customer: Why do I see ugly borders around the edges of my sprites ? (or sometimes: Why does</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10144010</link><pubDate>Mon, 21 Mar 2011 20:57:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10144010</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; The answer to &amp;quot;Customer: Why do I see ugly borders around the edges of my sprites?&amp;quot; is to have them export their texture using a file format (such as PNG) that supports an 8-bit alpha channel.&lt;/p&gt;
&lt;p&gt;Except that doesn&amp;#39;t solve the problem &amp;nbsp;:-)&lt;/p&gt;
&lt;p&gt;Premultiplied alpha has nothing to do with faking transparency for web graphics &amp;nbsp;(although most web based composition systems such as Flash or Silverlight do all their rendering using premultiplied colors, fo the same reasons that XNA 4.0 does).&lt;/p&gt;
&lt;p&gt;Regardless of whether you use an image format with an 8 bit alpha channel or not, if you choose something other than premulitplied color format, you will suffer from incorrect interpolation any time you filter an image, not to mention finding it fundamentally impossible to make any kind of layered image composition produce sensible results.&lt;/p&gt;
&lt;p&gt;Sure, it can be painful to convert a large existing project from one color format to another. That&amp;#39;s why you should use premultiplied alpha right from the start!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10144010" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10143998</link><pubDate>Mon, 21 Mar 2011 20:15:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10143998</guid><dc:creator>Kent</dc:creator><description>&lt;p&gt;This change caused a lot of headache for me. In your other article you say, &amp;quot;But most paint programs and image file formats do not use premultiplied alpha!&amp;quot;, which is completely correct. That alone, in my opinion, should be why non-premultiplied should be the default.&lt;/p&gt;
&lt;p&gt;The answer to &amp;quot;Customer: Why do I see ugly borders around the edges of my sprites?&amp;quot; is to have them export their texture using a file format (such as PNG) that supports an 8-bit alpha channel.&lt;/p&gt;
&lt;p&gt;Premultiplied alpha is perfect for &amp;quot;faking&amp;quot; transparency in web graphics where the background color can be assumed. For dynamic games though? It seems like a lot of trouble.&lt;/p&gt;
&lt;p&gt;Always enjoy reading your blog Shawn, keep up the great work (Just don&amp;#39;t go making too many breaking changes!)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10143998" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10124002</link><pubDate>Wed, 02 Feb 2011 22:05:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10124002</guid><dc:creator>Unallied</dc:creator><description>&lt;p&gt;Interesting stuff, I&amp;#39;m just now trying to upgrade a 3.1 project to 4.0 and this Color constructor thing sucks... Two things I found really confusing, 1) why couldn&amp;#39;t you leave in a constructor that took those arguments and just built it with the new operator color*(alpha/255f)? and 2) why the Color*float operator does not work in the other direction (float*Color)?&lt;/p&gt;
&lt;p&gt;For (2) I would assume that you couldn&amp;#39;t add a float operator overload for some reason? &amp;nbsp;But for other XNA classes like Vector2,3,4 you can. &amp;nbsp;Or is it a semantic thing you want to specifically enforce?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10124002" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10009761</link><pubDate>Sun, 09 May 2010 01:31:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009761</guid><dc:creator>Ben</dc:creator><description>&lt;p&gt;To answer my own question, if anyone else wants to &amp;nbsp;use premultiplied alpha in XNA4, but not load their textures from the content pipeline, I pasted a (probably inefficient) solution here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://codepaste.net/6h1pgt"&gt;http://codepaste.net/6h1pgt&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009761" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10009694</link><pubDate>Sat, 08 May 2010 20:44:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009694</guid><dc:creator>Ben</dc:creator><description>&lt;p&gt;&amp;gt;Correct. If you don't go through our Content Pipeline, you have to handle the format conversion yourself, or just not use premultiplied alpha.&lt;/p&gt;
&lt;p&gt;Can you (or anyone) give a hint as to how one would go about processing a Texture2D.FromStream texture for premultiplied alpha?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009694" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10008737</link><pubDate>Thu, 06 May 2010 20:09:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10008737</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; Now that PMA is standard, does it mean that if I set my tint_color.a=0 in the spritebatch.draw while letting tint_color.rgb normal then I would get an additive blending?&lt;/p&gt;
&lt;p&gt;That's exactly what happens with premultiplied alpha, yes.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10008737" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#10006220</link><pubDate>Mon, 03 May 2010 10:04:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10006220</guid><dc:creator>Roys</dc:creator><description>&lt;p&gt;Now that PMA is standard, does it mean that if I set my tint_color.a=0 in the spritebatch.draw while letting tint_color.rgb normal then I would get an additive blending?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10006220" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#9993711</link><pubDate>Sat, 10 Apr 2010 17:49:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9993711</guid><dc:creator>Shawn Hargreaves - MSFT</dc:creator><description>&lt;p&gt;&amp;gt; can you recommend any reading on the subject of color math?&lt;/p&gt;
&lt;p&gt;Computer Graphics: Principles and Practice (by Foley, Van Dam, etc) is one of the classic texts of the computer graphics world. It's a little dated now, and doesn't talk about premultiplied alpha, but has some good background information about different color spaces and chroma representation.&lt;/p&gt;
&lt;p&gt;About premultiplied alpha specifically, Tom Forsyth has a great article on his blog (&lt;a rel="nofollow" target="_new" href="http://home.comcast.net/~tom_forsyth/blog.wiki.html"&gt;http://home.comcast.net/~tom_forsyth/blog.wiki.html&lt;/a&gt;). And here is the original paper on this stuff: &lt;a rel="nofollow" target="_new" href="http://portal.acm.org/citation.cfm?id=808606"&gt;http://portal.acm.org/citation.cfm?id=808606&lt;/a&gt;. I've blogged about this in the past, too.&lt;/p&gt;
&lt;p&gt;Once you learn to read them (not always easy if you don't have a mathematical/academic background!) SIGGRAPH papers are an awesome source of theoretical background on just about everything.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9993711" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#9993521</link><pubDate>Sat, 10 Apr 2010 00:36:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9993521</guid><dc:creator>Rob</dc:creator><description>&lt;p&gt;Shawn, can you recommend any reading on the subject of color math? I'm very interested in learning the theory behind all of this. Thanks!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9993521" width="1" height="1"&gt;</description></item><item><title>re: Premultiplied alpha in XNA Game Studio 4.0</title><link>http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx#9993332</link><pubDate>Fri, 09 Apr 2010 18:46:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9993332</guid><dc:creator>cambrium studios</dc:creator><description>&lt;p&gt;Thanks Shawn for all these articles describing the XNA 4.0 changes in such clear language, and especially giving the *reasons* for these changes!&lt;/p&gt;
&lt;p&gt;Right now I am staying with XNA 3.1 since these changes would break too much of my existing code, but I do have the very strong feeling that all these changes (color format, rendertargets, renderstates, ...) make a lot of sense and are further adding a lot of both ease as well as professionalism to XNA! :-)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9993332" width="1" height="1"&gt;</description></item></channel></rss>