<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Catalin&#039;s XNA Blog</title>
	<atom:link href="http://www.catalinzima.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.catalinzima.com</link>
	<description>XNA Tutorials, Samples and Thoughts</description>
	<lastBuildDate>Tue, 20 Sep 2011 19:51:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>2D Pie Drawing updated to 4.0</title>
		<link>http://www.catalinzima.com/2011/09/2d-pie-drawing-updated-to-4-0/</link>
		<comments>http://www.catalinzima.com/2011/09/2d-pie-drawing-updated-to-4-0/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 19:51:19 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[sample]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=765</guid>
		<description><![CDATA[UberGeekGames just provided me with an version of the Pie Drawing sample, updated to XNA 4.0 You can find it on the sample&#8217;s page, or download it directly from here. Enjoy!]]></description>
			<content:encoded><![CDATA[<p><a href="http://ubergeekgames.com/">UberGeekGames </a>just provided me with an version of the <a href="http://www.catalinzima.com/samples/12-months-12-samples-2008/2d-pie-drawing/">Pie Drawing</a> sample, updated to XNA 4.0</p>
<p>You can find it on the sample&#8217;s <a href="http://www.catalinzima.com/samples/12-months-12-samples-2008/2d-pie-drawing/">page</a>, or download it directly from <a href="http://www.catalinzima.com/files/samples/Pie2DSample_4_0.zip">here</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/09/2d-pie-drawing-updated-to-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D Skeletal Animations</title>
		<link>http://www.catalinzima.com/2011/06/2d-skeletal-animations/</link>
		<comments>http://www.catalinzima.com/2011/06/2d-skeletal-animations/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 21:27:25 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Sample]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=739</guid>
		<description><![CDATA[What is your preferred way of doing animations in 2D? Most of you will probably answer &#8220;spritesheets&#8221;, and you&#8217;d be right. Creating animations using spritesheets is quick, easy, there are helpful resources on the net and if you work with an external artist, he only needs to give you the individual frames of the animation]]></description>
			<content:encoded><![CDATA[<p>What is your preferred way of doing animations in 2D?</p>
<p>Most of you will probably answer &#8220;spritesheets&#8221;, and you&#8217;d be right. Creating animations using spritesheets is quick, easy, there are helpful resources on the net and if you work with an external artist, he only needs to give you the individual frames of the animation (which also makes his life easy).</p>
<p>You would want to have a framerate of at least 12 for your animations, and you soon end up with something like this:</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2011/06/animation1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="Example Animation" src="http://www.catalinzima.com/wp-content/uploads/2011/06/animation_thumb.png" border="0" alt="Example Animation" width="240" height="114" /></a></p>
<p>And with minimal effort, you can write code that loads this and displays it as an animation [<a title="Sprite Sheet Animation" href="http://catalinzima.com/files/2011/samples/SpriteSheetAnimation.zip">SpriteSheetAnimation.zip</a>]</p>
<p><object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/zUqG9B66aEI?version=3&amp;hl=en_US" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="425" height="349" src="http://www.youtube.com/v/zUqG9B66aEI?version=3&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>All is well in the world, until you realize your game needs LOTS of animations and the memory consumption goes way up, together with the time required to load all the data. Also, to limit the size, you need to limit yourself to a low FPS for the animation (like 12), which also means the animation doesn’t look as smooth as you’d like. This is where skeletal animation comes in.</p>
<p>When using skeletal animation, the animation is composed of several bones which are connected to one another. Affecting a bone also affects all of its children. By composing different transformations on each bone, you obtain different poses for the skeleton.</p>
<p>Now, if you define keyframes with certain transformations for a point in time for each of the bones in the skeleton, you can interpolate between the keyframes to obtain a smooth transition and thus animate the skeleton.</p>
<p>In the attached code, I used a class named Transformation, which contains data about 2D transformations, like translation, rotation and scale. Then, a Keyframe is defined by a frame number and one such Transformation. A collection of Keyframes defines a KeyframeAnimation. Finally, a SkeletonAnimation is a collection of KeyframeAnimations, one for each bone in the skeleton.</p>
<p>Separately, I use a Skeleton, which keeps a list of Joints that define the hierarchy of bones in the skeleton. Each bone is then assigned a certain texture, like the ones below:</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_arm.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="machine_arm" src="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_arm_thumb.png" border="0" alt="machine_arm" width="82" height="64" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_forearm.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="machine_forearm" src="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_forearm_thumb.png" border="0" alt="machine_forearm" width="48" height="120" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_hookLeft.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="machine_hookLeft" src="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_hookLeft_thumb.png" border="0" alt="machine_hookLeft" width="27" height="41" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_hookRight.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="machine_hookRight" src="http://www.catalinzima.com/wp-content/uploads/2011/06/machine_hookRight_thumb.png" border="0" alt="machine_hookRight" width="31" height="50" /></a></p>
<p>Each of the parts are individually animated relative to their parent bone, and thus the animation is obtained. In the sample, the animation is stored in two XML files that are loaded directly into a Skeleton (see <a href="http://catalinzima.com/files/2011/samples/machine_skeleton.xml">machine_skeleton.xml</a> ) and a SkeletonAnimation (see <a href="http://catalinzima.com/files/2011/samples/machine_animation.xml">machine_animation.xml</a> ) using the ContentPipeline at runtime. Here’s a video of the sample using skeleton animation:</p>
<p><object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/Tc8LGf91_q0?version=3&amp;hl=en_US" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="425" height="349" src="http://www.youtube.com/v/Tc8LGf91_q0?version=3&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>As you can see, it runs much smoother than the initial frame-based animation. Also, looking at the resources used, the amount of texture data loaded into memory is significantly reduced (from 5.12 Mb to only 73Kb).</p>
<p>A word on how the XML file was generated. There are multiple options here.</p>
<ul>
<li>make a tool for editing animations, where you would set-up the positions of each frame and serialize it to disk using the IntermediateSerializer.</li>
<li>let your artist create the animation in a software of is choice that can output the keyframes to XML, and then write a small program that converts that XML in the suitable format to be loaded by the Content Pipeline. For the animation above, I used a Flash animation created by a friend, exported the keyframes to ActionScript3 XML, and then converted that XML into the one you can see in the sample. (I won’t release that mini-tool however, since its code is a mess thrown together in about 1 hour).</li>
</ul>
<p>A word of warning: while skeletal animation helps solve some problems with memory, loading times, smoothness, it is not a silver bullet. The amount of detail that can go into a normal sprite-sheet animation far surpasses what can be done with a skeletal animation. In skeletal animations you are limited to certain transformations on each ‘piece’ of the animation: translate, rotate, scale, flip. Meanwhile, frame-based animation allows the artist to add any kind of effect he likes.</p>
<p>I hope you enjoyed this sample. Feel free to leave any feedback and questions below.</p>
<p>To get the code, either download it directly (<a href="http://catalinzima.com/files/2011/samples/SkeletalAnimation.zip">SkeletalAnimation.zip</a>) or go to the <a href="http://www.catalinzima.com/samples/year-2011/2d-skeletal-animation/">sample’s page</a>.</p>
<p>Until next time,</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/06/2d-skeletal-animations/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>License Updated</title>
		<link>http://www.catalinzima.com/2011/06/license-updated/</link>
		<comments>http://www.catalinzima.com/2011/06/license-updated/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 20:35:55 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[license]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=725</guid>
		<description><![CDATA[Hi all, I&#8217;ve updated the license for all code downloadable from this site. The licensing terms can be read here. In short, the code is licensed under MIT, so you can use it freely (unless otherwise stated specifically). However, I need to protect myself and my collaborators, so all content (images, sounds, etc) is not]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>I&#8217;ve updated the license for all code downloadable from this site. The licensing terms can be read <a title="License" href="http://www.catalinzima.com/license/">here</a>.</p>
<p>In short, the <strong>code </strong>is licensed under MIT, so you can use it <strong>freely </strong>(unless otherwise stated specifically).</p>
<p>However, I need to protect myself and my collaborators, so all <strong>content </strong>(images, sounds, etc) is not licensed, so <strong>you may not distribute it</strong> or use it in other circumstances than to be able to build and run the code as provided here for educational purposes.</p>
<p>These terms should satisfy most visitors on this site <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/06/license-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVP Summit 2011</title>
		<link>http://www.catalinzima.com/2011/03/mvp-summit-2011/</link>
		<comments>http://www.catalinzima.com/2011/03/mvp-summit-2011/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 11:10:28 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[Summit]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[XBLIG]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=707</guid>
		<description><![CDATA[The first week of March I was together with a few other XNA MVPs at the Microsoft MVP Summit 2011 in Seattle. I&#8217;d love to be able to tell you stuff we&#8217;ve learned there, or as Andy would also wish, to be able to tell you news about current issues you all know with XBLIG]]></description>
			<content:encoded><![CDATA[<p>The first week of March I was together with a few other XNA MVPs at the Microsoft MVP Summit 2011 in Seattle.</p>
<p>I&#8217;d love to be able to tell you stuff we&#8217;ve learned there, or <a href="http://forums.create.msdn.com/forums/t/77625.aspx">as Andy would also wish</a>, to be able to tell you news about current issues you all know with XBLIG and the <span style="text-decoration: line-through;">Creator&#8217;s Club</span> AppHub site and forums. All guys present there were careful to repeatedly remind the team of the issues (especially George).</p>
<p>Of course, bound by our NDA&#8217;s we can&#8217;t share stuff we found out, but maybe we can tell you some things that might put you at ease.</p>
<ul>
<li>XBLIG is here to stay. Even if the WP7 side of things drew some focus away from the 360 side for a while, rest assured that the team is invested in XBLIG and they&#8217;re not letting it go anytime soon</li>
<li>the previews we saw of what&#8217;s coming in the future of the phone side were great and you&#8217;ll love it all</li>
<li>All teams are listening to feedback and doing their best to act on it</li>
<li>Silence does not mean lack of interest on their part</li>
</ul>
<p>Yes, Microsoft is not always moving as fast as we&#8217;d wish; Yes, there are pressing issues with the site; Yes, on some points they are behind the competition at this point&#8230; but I feel that YES, these (XNA, WP7, XBLIG) are awesome platforms to be on, only getting stronger, and having a great future.</p>
<p>On a personal note, this was a good summit. I had a great time with the other MVPs and met some great people in Microsoft, who I want to thank for their time and effort.</p>
<p>Also, I got a signed copy (thanks <a href="http://geekswithblogs.net/clingermangw/Default.aspx">George</a> and <a href="http://geekswithblogs.net/cwilliams/Default.aspx">Chris</a>) of this:</p>
<p><a href="http://www.amazon.com/Professional-Windows-Phone-Game-Development/dp/0470922443"><img class="alignnone" title="Professional Windows Phone Game Development" src="http://ecx.images-amazon.com/images/I/51C0u7M%2BBhL._SL500_AA300_.jpg" alt="" width="300" height="300" /></a></p>
<p>It&#8217;s a fantastic book, the writing style is fun, which makes it a real pleasure to read. And on the technical side, being written by these two guys, it&#8217;s probably the best you can get on the subject. The single complaint is that the <a href="http://geekswithblogs.net/clingermangw/archive/2011/02/05/143827.aspx">tattoo</a> didn&#8217;t make it on the cover.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/03/mvp-summit-2011/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Chickens Can Dream</title>
		<link>http://www.catalinzima.com/2011/02/chickens-can-dream/</link>
		<comments>http://www.catalinzima.com/2011/02/chickens-can-dream/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 23:28:54 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[AmusedSloth]]></category>
		<category><![CDATA[Chickens Can Dream]]></category>
		<category><![CDATA[Chickens Can't Fly]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=695</guid>
		<description><![CDATA[Well, this caught me off-guard&#8230; When we submitted the game last Sunday, I was hoping the game would get through certification sooner, but apparently it decided to come out just as I was starting my long trip towards Seattle. I&#8217;m proud to say that Chickens Can Dream just went live on the Windows Phone 7]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.catalinzima.com/wp-content/uploads/2011/02/logo_with_title.png"><img class="aligncenter size-large wp-image-699" title="Chickens Can Dream" src="http://www.catalinzima.com/wp-content/uploads/2011/02/logo_with_title-772x1024.png" alt="" width="463" height="614" /></a></p>
<p>Well, this caught me off-guard&#8230; <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  When we submitted the game last Sunday, I was hoping the game would get through certification sooner, but apparently it decided to come out just as I was starting my long trip towards Seattle. I&#8217;m proud to say that <strong><a href="http://www.amusedsloth.com/games/chickens-can-dream/">Chickens Can Dream</a></strong> just went live on the Windows Phone 7 Marketplace on Friday.</p>
<p>Go ahead and <a href="http://social.zune.net/redirect?type=phoneApp&amp;id=3282eec1-263d-e011-854c-00237de2db9e">download it</a> (it&#8217;s free) if you haven&#8217;t already and let me know what you think <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>While Chickens Can Dream is just a milestone in the wonderful adventure that is the <a href="http://www.amusedsloth.com/games/chickens-cant-fly/"><strong>Chickens Can&#8217;t Fly</strong></a> project, it&#8217;s also a great achievement for me. While this is certainly not my first game, or not even the first game I&#8217;ve worked on that got published, I can certainly say it is the game I&#8217;ve put most of myself into, am most proud of and most excited about sharing with you (all 6 of you that still read my blog <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).<br />
It&#8217;s definitely not perfect yet, and we&#8217;re working on the next update for it as we speak (at least my team is, I&#8217;m on a plane flying over Canada), but our goal with <strong>Chickens Can Dream</strong> was to get it out there and get feedback on it.</p>
<p>Besides letting you know about the game and giving you the download link, I also wanted to take this opportunity to congratulate and thank my team and people that made this possible, so here goes:</p>
<ul>
<li><strong>Razvan </strong>and <strong>Razvan </strong>- for all the brainstorming sessions where they helped refine my design and especially for all the code they wrote.</li>
</ul>
<ul>
<li> <strong>Hashu </strong>- for the great art he created for the game and for suffering through our feedback on the art drafts</li>
</ul>
<ul>
<li> <strong>Gabi </strong>and <strong>Flaviu </strong>- for the last few weeks helping us get highscores and online services in the game.</li>
</ul>
<ul>
<li> <strong>Lidia </strong>- for helping me see errors in my designs every time she played whatever build I had on my phone (<em>and for coming up to our floor to make us take breaks from time to time</em>). Even though she&#8217;s a gamer, she was invaluable in ensuring the game is suited for a large non-gamer audience.</li>
</ul>
<ul>
<li> <strong>Robert,</strong> <strong>Gabi </strong>and <strong>Claudiu</strong>- for trusting us and giving us the opportunity and resources to create this game.</li>
</ul>
<ul>
<li> All people who played various builds of the game &#8211; for being test subjects.</li>
</ul>
<p>Thank you all!</p>
<p>Download the game now because we want to know how to make <strong>Chickens Can&#8217;t Fly</strong> better!</p>
<p><a class="download_btn_red" href="http://social.zune.net/redirect?type=phoneApp&amp;id=3282eec1-263d-e011-854c-00237de2db9e">Download for Windows Phone 7</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/02/chickens-can-dream/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>In case you missed it&#8230;</title>
		<link>http://www.catalinzima.com/2011/01/in-case-you-missed-it/</link>
		<comments>http://www.catalinzima.com/2011/01/in-case-you-missed-it/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 21:33:09 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[AmusedSloth]]></category>
		<category><![CDATA[Chickens Can't Fly]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Trailer]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=692</guid>
		<description><![CDATA[Here&#8217;s the teaser trailer for Chickens Can&#8217;t Fly. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the teaser trailer for <a href="http://www.amusedsloth.com/games/chickens-cant-fly/">Chickens Can&#8217;t Fly</a>. Enjoy!</p>
<p><iframe title="YouTube video player" type="text/html" width="560" height="345" src="http://www.youtube.com/embed/TyxkZJL-feI?rel=0&amp;hd=1" frameborder="0" allowFullScreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/01/in-case-you-missed-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screen-space deformations in XNA for WP7</title>
		<link>http://www.catalinzima.com/2011/01/screen-space-deformations-in-xna-for-wp7/</link>
		<comments>http://www.catalinzima.com/2011/01/screen-space-deformations-in-xna-for-wp7/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 21:30:30 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[AmusedSloth]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[postprocessing]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=688</guid>
		<description><![CDATA[I posted a new tutorial recently about applying deformations as a post-processing&#8230; process using only stuff available in the Reach profile, without any shaders. This configuration is useful for Windows Phone 7. Go ahead and read the whole article here.]]></description>
			<content:encoded><![CDATA[<p>I posted a new tutorial recently about applying deformations as a post-processing&#8230; process using only stuff available in the Reach profile, without any shaders. This configuration is useful for Windows Phone 7.</p>
<p>Go ahead and read the whole article <a href="http://www.amusedsloth.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2011/01/screen-space-deformations-in-xna-for-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA 4.0 version of the Deferred Rendering code</title>
		<link>http://www.catalinzima.com/2010/12/xna-4-0-version-of-the-deferred-rendering-code/</link>
		<comments>http://www.catalinzima.com/2010/12/xna-4-0-version-of-the-deferred-rendering-code/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 17:04:19 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Deferred Rendering]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Roy]]></category>
		<category><![CDATA[XNA 4.0]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=655</guid>
		<description><![CDATA[Roy Triesscheijn just posted an updated version of the code he obtained after following my Deferred Rendering tutorial. You can read all about it on Roy&#8217;s blog, here. So we now have a working 4.0 version of the tutorial. Thanks, Roy!]]></description>
			<content:encoded><![CDATA[<p>Roy Triesscheijn just posted an updated version of the code he obtained after following my <a href="http://www.catalinzima.com/tutorials/deferred-rendering-in-xna/">Deferred Rendering tutorial</a>.</p>
<p>You can read all about it on Roy&#8217;s blog, <a href="http://roy-t.nl/index.php/2010/12/28/deferred-rendering-in-xna4-0-source-code/">here</a>.</p>
<p>So we now have a working 4.0 version of the tutorial. <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thanks, Roy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2010/12/xna-4-0-version-of-the-deferred-rendering-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My first game and AmusedSloth site launched!</title>
		<link>http://www.catalinzima.com/2010/12/my-first-game-and-amusedsloth-site-launched/</link>
		<comments>http://www.catalinzima.com/2010/12/my-first-game-and-amusedsloth-site-launched/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 20:14:13 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[AmusedSloth]]></category>
		<category><![CDATA[Announcements]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Amused Sloth]]></category>
		<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Chickens Can't Fly]]></category>
		<category><![CDATA[Rebellion Rise]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=656</guid>
		<description><![CDATA[The company I work at, where I&#8217;m leading the efforts of the Windows Phone 7 department, has just launched our new site, with our identity for all our current and future mobile games and apps (and possibly XBLIG games also). I&#8217;m proud to point you to the AmusedSloth.com site, which is now online. Here you]]></description>
			<content:encoded><![CDATA[<p>The company I work at, where I&#8217;m leading the efforts of the Windows Phone 7 department, has just launched our new site, with our identity for all our current and future mobile games and apps (and possibly XBLIG games also).</p>
<p>I&#8217;m proud to point you to the <strong><a href="http://www.amusedsloth.com/">AmusedSloth.com</a></strong> site, which is now online. Here you can find information about our games and apps.</p>
<h1>Rebellion Rise</h1>
<p>The first game that we launched is <strong><a href="http://www.amusedsloth.com/rebellionrise.html">Rebellion Rise</a></strong>, a space shooter where you get to fight giant motherships. Watch the launch trailer below.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="340" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/kFjBieCT6vg?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="340" src="http://www.youtube.com/v/kFjBieCT6vg?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>You can try the game on the Windows Phone Marketplace right now. Really&#8230; like&#8230; <a href="http://social.zune.net/redirect?type=phoneApp&amp;id=e3c451b1-1d0d-e011-9264-00237de2db9e">right now</a> <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ( Thanks ) Let me know in the comments what you think about it and if you have any technical questions <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I don&#8217;t want to &#8216;promise&#8217; anything, but I plan to release a small sample showing off how we pulled the deformations and shockwave effects without using shaders.</p>
<p>I will also take this opportunity to announce what our next game will be. I can&#8217;t wait to release more information about it but right now it&#8217;s only going to be some screenshots ( gotta follow the marketing plan ). So, our next game is called&#8230;. <a href="http://www.amusedsloth.com/chickenscantfly.html">Chickens Can&#8217;t Fly</a>, and you can see two screenshots of it below (and a few more on the site)</p>
<h1>Chickens Can&#8217;t Fly</h1>
<p><a href="http://www.amusedsloth.com/images/chicken/screen4.png"><img class=" alignnone" title="Can Chicken drink and dive?" src="http://www.amusedsloth.com/images/chicken/screen4.png" alt="Can Chicken drink and dive?" width="166" height="277" /></a> <a href="http://www.amusedsloth.com/images/chicken/screen2.png"><img class=" alignnone" title="Is Chicken afraid of cacti?" src="http://www.amusedsloth.com/images/chicken/screen2.png" alt="Is Chicken afraid of cacti?" width="166" height="277" /></a></p>
<p>You&#8217;ll be hearing more about it in January. <a href="http://www.chickenscantfly.com/">That&#8217;s a promise!</a> <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now you know what I&#8217;ve been doing in the last 6 months! I hope things go well, as WP7 is a great platform and having XNA to use as an API is absolutely terrific.</p>
<p>As I said above, comments and suggestion are welcome. Thanks!</p>
<p><span style="font-size: 0.8em;"><br />
P.S. I know there are some issues with the site, and our guys are working hard on fixing them early in January.<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2010/12/my-first-game-and-amusedsloth-site-launched/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My technique for the shader-based dynamic 2D shadows</title>
		<link>http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/</link>
		<comments>http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 20:36:53 +0000</pubDate>
		<dc:creator>Catalin Zima</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[details]]></category>
		<category><![CDATA[Finally!]]></category>
		<category><![CDATA[Shadows]]></category>

		<guid isPermaLink="false">http://www.catalinzima.com/?p=620</guid>
		<description><![CDATA[It’s been a long time coming, but finally I get the time to explain the technique I came up with for drawing shader-based dynamic 2D shadows. If you want to dive right into the code, you can go to the sample’s page. Still here? Ok then, let’s get started. The core of the technique is]]></description>
			<content:encoded><![CDATA[<p>It’s been a long time coming, but finally I get the time to explain the technique I came up with for drawing shader-based dynamic 2D shadows.</p>
<p>If you want to dive right into the code, you can go to the <a href="http://www.catalinzima.com/?page_id=623">sample’s page</a>.</p>
<p>Still here? Ok then, let’s get started.</p>
<p>The core of the technique is drawing all the possible shadow casters around a light into a texture, and then using a few shaders to turn this image into one containing all shadows cast in the scene. First, for a general view, consider the following scene.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/0_unlit_Scene.png"><img class="wlDisabledImage" style="margin: 5px; display: inline;" title="0_unlit_Scene" src="http://www.catalinzima.com/wp-content/uploads/2010/07/0_unlit_Scene_thumb.png" alt="0_unlit_Scene" width="560" height="336" /></a></p>
<p>Out goal is to have all objects cast shadows, with the two orange squares being the sources of light.</p>
<p>The first step is to build for each light a image of all the casters around it. This basically means drawing all objects with a black color into a texture, centered around the light. The technical side of this should be pretty trivial, and can also be seen in the code.<br />
<a href="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light1.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="1_casters_light1" src="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light1_thumb.png" border="0" alt="1_casters_light1" width="260" height="260" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light2.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="1_casters_light2" src="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light2_thumb.png" border="0" alt="1_casters_light2" width="260" height="260" /></a></p>
<p>The tricky part comes next and this is the main part of the technique. I will explain the whole process a little later, but for now just know that the technique I use takes as input these “caster maps” and produces a “shadow image”, as seen below.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/7_shadows_blured_attenuated.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="7_shadows_blured_attenuated" src="http://www.catalinzima.com/wp-content/uploads/2010/07/7_shadows_blured_attenuated_thumb.png" border="0" alt="7_shadows_blured_attenuated" width="260" height="260" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/8_shadows_2.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="8_shadows_2" src="http://www.catalinzima.com/wp-content/uploads/2010/07/8_shadows_2_thumb.png" border="0" alt="8_shadows_2" width="260" height="260" /></a></p>
<p>Having these two shadow images, it is now easy to blend them together, using the desired light color for each, and then blending the result over the “ground”.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/9_shadows_combined.png"><img class="wlDisabledImage" style="margin: 5px; display: inline;" title="9_shadows_combined" src="http://www.catalinzima.com/wp-content/uploads/2010/07/9_shadows_combined_thumb.png" alt="9_shadows_combined" width="560" height="420" /></a></p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/10_ground.png"><img class="wlDisabledImage" style="margin: 5px; display: inline;" title="10_ground" src="http://www.catalinzima.com/wp-content/uploads/2010/07/10_ground_thumb.png" alt="10_ground" width="560" height="420" /></a><br />
In the end, drawing the items in the scene leads to our desired result.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/11_scene.png"><img class="wlDisabledImage" style="margin: 5px; display: inline;" title="11_scene" src="http://www.catalinzima.com/wp-content/uploads/2010/07/11_scene_thumb.png" alt="11_scene" width="560" height="420" /></a></p>
<p>Most of these steps should be fairly easy. The problem comes in getting from the image containing all the shadow casters to the image containing the shadows themselves.</p>
<p>The technique is really not that complicated, so I’ll explain each step, together with shader code and images. So let’s start with the beginning, namely the shadow casters image.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light11.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="1_casters_light1" src="http://www.catalinzima.com/wp-content/uploads/2010/07/1_casters_light1_thumb1.png" border="0" alt="1_casters_light1" width="260" height="260" /></a><br />
<strong>1.</strong> Starting from this, for each non-transparent pixel (non-white in the illustration), I output the distance from the center of the texture to that pixel (i.e. the distance from the light source to the pixel).</p>
<pre class="brush: plain; title: ; notranslate">
float4 ComputeDistancesPS(float2 TexCoord : TEXCOORD0) : COLOR0
{
float4 color = tex2D(inputSampler, TexCoord);
     //compute distance from center
float distance = color.a&amp;gt;0.3f?length(TexCoord - 0.5f):1.0f;
//save it to the Red channel
distance *= renderTargetSize.x;
return float4(distance,0,0,1);
}
</pre>
<p>One thing to notice is that I multiply by the size of the render target and save to a floating point format. I do this in order to preserve precision. You could store this as a value between 0 and 1, and write it into a render target with the Color surface format, but this can lead to some imprecision when using large lights.</p>
<p>The results looks something like below (shown in grayscale for easy visualization).</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/2_distances.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="2_distances" src="http://www.catalinzima.com/wp-content/uploads/2010/07/2_distances_thumb.png" border="0" alt="2_distances" width="260" height="260" /></a><br />
<strong>2.</strong> In the next step, I divide the image into four quadrants around the light (center of this image), and distort it in such a way that all “light rays” (which are at the moment spreading in all directions from the light) are positioned in parallel. This is much easier to understand with an image, as seen below.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/2_distancesmarked.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="2_distancesmarked" src="http://www.catalinzima.com/wp-content/uploads/2010/07/2_distancesmarked_thumb.png" border="0" alt="2_distancesmarked" width="260" height="260" /></a><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedXCopy.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="3_distortedX - Copy" src="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedXCopy_thumb.png" border="0" alt="3_distortedX - Copy" width="260" height="260" /></a><br />
In the pictures above, the quadrant to the left (and the one to the right) has been distorted so it takes up half of the image, and all pixels are placed as if the rays starting from the light are parallel. The reason I am doing this will be obvious in the next step. Since I need this data for all the quadrants, I make the same operation for the vertical direction (rotating the result so it’s also horizontal).</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedY.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="3_distortedY" src="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedY_thumb.png" border="0" alt="3_distortedY" width="260" height="260" /></a></p>
<p>I know the text doesn’t make as much sense as I would like but hopefully the images illustrate what I mean. Finally, to reduce memory usage and to perform more computations in parallel, I store the result of the horizontal distortion in the red channel, and the result of the vertical distortion in the green channel.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedCombine.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="3_distortedCombine" src="http://www.catalinzima.com/wp-content/uploads/2010/07/3_distortedCombine_thumb.png" border="0" alt="3_distortedCombine" width="244" height="244" /></a><br />
I know it doesn’t look like much, but know that all the data we need for all directions is now stored in a single texture. The code that achieves this step is the shader function below. This code can probably be simplified (to avoid the conversions between the [0,1] and [-1,1] domains, but I find it clearer this way.</p>
<pre class="brush: plain; title: ; notranslate">
float4 DistortPS(float2 TexCoord : TEXCOORD0) : COLOR0
{
//translate u and v into [-1 , 1] domain
float u0 = TexCoord.x * 2 - 1;
float v0 = TexCoord.y * 2 - 1;

//then, as u0 approaches 0 (the center), v should also approach 0
v0 = v0 * abs(u0);
//convert back from [-1,1] domain to [0,1] domain
v0 = (v0 + 1) / 2;
//we now have the coordinates for reading from the initial image
float2 newCoords = float2(TexCoord.x, v0);

//read for both horizontal and vertical direction and store them in separate channels

float horizontal = tex2D(inputSampler, newCoords).r;
float vertical = tex2D(inputSampler, newCoords.yx).r;
return float4(horizontal,vertical ,0,1);
}</pre>
<p><strong>3. </strong>Now that we have the distorted images of the distances from the light along each ray going out from the light, it’s time to compute the minimum along each of these rays. I do this by successive reduction of the image along the horizontal direction, until a texture of width 2 is obtained. This texture is something very similar to a shadow map in 3D, in that it contains for each ray, the minimum distance from the light where a shadow caster is present.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/4_shadowMap.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="4_shadowMap" src="http://www.catalinzima.com/wp-content/uploads/2010/07/4_shadowMap_thumb.png" border="0" alt="4_shadowMap" width="6" height="244" /></a></p>
<p>This step is also currently the bottleneck of the algorithm, since reducing a texture of 512*512 to a size of 2*512 requires about 9 passes (the dimension is reduced by a factor of 2 through each pass). The reduction shader is a simple one:</p>
<pre class="brush: plain; title: ; notranslate">
float4 HorizontalReductionPS(float2 TexCoord : TEXCOORD0) : COLOR0
{
float2 color = tex2D(inputSampler, TexCoord);
float2 colorR = tex2D(inputSampler, TexCoord + float2(TextureDimensions.x,0));
float2 result = min(color,colorR);
return float4(result,0,1);
}</pre>
<p>At this point, it should be clear why I distorted the pixels in such a way (in order to be able to apply a horizontal reduction) and why the vertical components were also rotated and stored in a separate channel. Basically, we make the reductions on all directions at the same time.</p>
<p><em>Note: because this is the bottleneck, an option is to store the caster texture and do all operation on half the size of the actual light area. Thus for a light area of 512*512 you could make the processing on textures of 256*256. This way you loose some crispiness (not always a bad thing when it comes to shadows) but you also gain some performance.</em></p>
<p><strong>4.</strong> At this moment, we can generate the shadow image. We draw the area surrounding the light, and for each pixel, we compare the distance between this pixel and the light to the distance stored in the shadow map along the same ray. This information tells us if we are in front or behind the shadow caster.</p>
<pre class="brush: plain; title: ; notranslate">
float4 DrawShadowsPS(float2 TexCoord: TEXCOORD0) : COLOR0
{
// distance of this pixel from the center
float distance = length(TexCoord - 0.5f);
distance *= renderTargetSize.x;

//apply a 2-pixel bias
distance -=2;

//distance stored in the shadow map
float shadowMapDistance;
//coords in [-1,1]
float nY = 2.0f*( TexCoord.y - 0.5f);
float nX = 2.0f*( TexCoord.x - 0.5f);

//we use these to determine which quadrant we are in
if(abs(nY)&amp;lt;abs(nX))
{
shadowMapDistance = GetShadowDistanceH(TexCoor
}
else
{
shadowMapDistance = GetShadowDistanceV(TexCoord);
}

//if distance to this pixel is lower than distance from shadowMap,
//then we are not in shadow
float light = distance &lt; shadowMapDistance ? 1:0;
float4 result = light;
result.b = length(TexCoord - 0.5f);
result.a = 1;
return result;
}</pre>
<p>The functions that read from the shadow map make an inverse transformation of coordinates in order to read from the proper location in the shadowmap.</p>
<pre class="brush: plain; title: ; notranslate">
float GetShadowDistanceH(float2 TexCoord)
{
 float u = TexCoord.x;
 float v = TexCoord.y;

 u = abs(u-0.5f) * 2;
 v = v * 2 - 1;
 float v0 = v/u;
 v0 = (v0 + 1) / 2;

 float2 newCoords = float2(TexCoord.x,v0);
 //horizontal info was stored in the Red component
 return tex2D(shadowMapSampler, newCoords).r;
}

float GetShadowDistanceV(float2 TexCoord)
{
 float u = TexCoord.y;
 float v = TexCoord.x;

 u = abs(u-0.5f) * 2;
 v = v * 2 - 1;
 float v0 = v/u;
 v0 = (v0 + 1) / 2;

 float2 newCoords = float2(TexCoord.y,v0);
 //vertical info was stored in the Green component
 return tex2D(shadowMapSampler, newCoords).g;
}
</pre>
</pre>
<p>(<em>Note: in the source code, you might notice a commented out version of the DrawShadowsPS function. That one was using three taps in order to smooth out the aliasing of the shadows, quite similar to what PCF method for 3D shadow maps does. This was left out because the smoothing through blur is much better looking</em>)</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/5_shadows_unfiltered_red.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="5_shadows_unfiltered_red" src="http://www.catalinzima.com/wp-content/uploads/2010/07/5_shadows_unfiltered_red_thumb.png" border="0" alt="5_shadows_unfiltered_red" width="244" height="244" /></a></p>
<p>Another thing to notice is that we store the distance from the center in the Blue component of the result. This is useful when we want to smooth out the shadows by applying Gaussian blur, with radius depending on the distance from the light. Thus we obtain harder shadows closer to the light source, and softer shadows further away.</p>
<p><strong>5. </strong>Next in my implementation, I apply a horizontal blur, followed by a vertical blur. The code for this is not too special, except for the fact that the blur radius depends on the distance from the light. All shader source can be seen in the attached archive, and I will not reproduce the blur shader here. When doing the final blur step, I also add some attenuation to the light, and the result is finally the one we were looking for.</p>
<p><a href="http://www.catalinzima.com/wp-content/uploads/2010/07/7_shadows_blured_attenuated1.png"><img class="wlDisabledImage" style="margin: 5px; display: inline; border-width: 0px;" title="7_shadows_blured_attenuated" src="http://www.catalinzima.com/wp-content/uploads/2010/07/7_shadows_blured_attenuated_thumb1.png" border="0" alt="7_shadows_blured_attenuated" width="244" height="244" /></a></p>
<p>And this concludes the explanations about the algorithm I used for the shader-based soft 2D shadows. I hope my explanations were clear enough <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://www.catalinzima.com/wp-content/uploads/2010/07/wlEmoticonsmile.png" alt="Smile" /></p>
<p>You can download the source code from the <a href="http://www.catalinzima.com/?page_id=623">sample’s page, found here</a>.</p>
<p>Until next time, have fun coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

