<?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>Olhovsky &#187; XNA</title>
	<atom:link href="http://www.olhovsky.com/tag/xna/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.olhovsky.com</link>
	<description>Programming, meet art.</description>
	<lastBuildDate>Mon, 23 Jan 2012 05:19:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Deferred lighting.</title>
		<link>http://www.olhovsky.com/2011/05/deferred-lighting/</link>
		<comments>http://www.olhovsky.com/2011/05/deferred-lighting/#comments</comments>
		<pubDate>Tue, 31 May 2011 15:34:46 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[deferred]]></category>
		<category><![CDATA[light pre pass]]></category>
		<category><![CDATA[lighting]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=761</guid>
		<description><![CDATA[My forward rendered lighting setup almost suited my purposes, but it turned out that the limitations of the XBOX CPU limited me to far too few terrain chunks, and therefore far too few lights. To this end, I&#8217;ve been exploring &#8230; <a href="http://www.olhovsky.com/2011/05/deferred-lighting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My <a title="Experimenting with a darker lighting setup." href="http://www.olhovsky.com/2011/04/some-point-light-testing/">forward rendered lighting setup</a> almost suited my purposes, but it turned out that the limitations of the XBOX CPU limited me to far too few terrain chunks, and therefore far <a title="Status update: Point light stress testing." href="http://www.olhovsky.com/2011/05/status-update-point-light-stress-testing/">too few lights</a>.</p>
<div id="attachment_655" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights2.png"><img class="size-medium wp-image-655" title="april01_point_lights2" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights2-300x175.png" alt="" width="300" height="175" /></a><p class="wp-caption-text">Maximum of 7 lights touching each chunk in the terrain shader, but chunks were far too large due to CPU limitations on the XBOX.</p></div>
<p>To this end, I&#8217;ve been exploring some deferred lighting options.</p>
<p>For the Xbox 360, an attractive option is light-pre-pass, which suits the Xbox much moreso than a fully deferred setup, as LPP uses less intermediate texture buffering, and therefore avoids Xbox 360 texture bandwidth limitations, and avoids predicated tiling issues.</p>
<p>J. Coluna has a good LPP example, and <a href="http://jcoluna.wordpress.com/2011/04/27/xna-4-0-light-pre-pass-casting-shadows/#comment-98">he was wondering</a> how to deal with the problem of being limited to 32 bit render target formats on the Xbox 360, yet wanting to store specular light data in the light buffer (for which I use HDRBlendable, on the xbox this format stores 10 bits for RGB and 2 bits for alpha).</p>
<div>
<p>If we had a 64 bit rendertarget, we&#8217;d have 16 bits for each channel, and (monochrome) specular color could be stored in the alpha.</p>
<p>On the xbox we have only 2 bits in the alpha.</p>
<p>I am currently not using a dedicated specular channel. Instead I&#8217;m accumulating  specular in the light buffer RGB channels. This means that you can’t use  a specular strength map, and it means that you can more easily exceed  the HDR “overbright” limits, since specular highlights are often close  to full brightness (or at least, they are always brighter than the diffuse color). However, it does allow you to have colored specular  highlights, which a single specular channel does not.</p>
<p>One idea I’ve been considering to work around this, is to pack the  specular into the 1010102 format using the 2 bit alpha, plus 1 bit in R  and 1 bit in B. Then, I would apply half of the specular to the RGB  channels, and store the other half in RBA (4 packed bits total).</p>
<p>Then your specular strength maps can at most reduce specular highlights by half.</p>
<p>However, if we are willing to sacrifice some range on the specular  highlights, and use only 6 bits for specular, we can apply 25% of the  specular to the RGB channels, and then store the remaining 75% of the  specular packed in RBA (4 bits worth). This would allow specular  strength maps to reduce specular highlights by up to 75%, which is  probably enough for decent results.</p>
<p>One drawback to this method is that we lose 1 bit of red and 1 bit of  blue channel information. This means that for red and blue, lights can  more easily reach the HDR overbright limit.</p>
<p>Which method suits your purpose depends on your application.</p>
<p>Part of the benefit of the LPP method, is that we can avoid much of  the texture bandwidth requirements that a full defferred setup requires —  making this a better fit for the XBOX. For this reason, I’ll be  avoiding using a second texture to store specular.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/deferred-lighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Game3&#8243; post-mortem. (Or how I learned to stop worrying and love development outside of the DBP competition.)</title>
		<link>http://www.olhovsky.com/2011/05/game3-post-mortem-or-how-i-learned-to-stop-worrying-and-love-development-outside-of-the-dbp-competition/</link>
		<comments>http://www.olhovsky.com/2011/05/game3-post-mortem-or-how-i-learned-to-stop-worrying-and-love-development-outside-of-the-dbp-competition/#comments</comments>
		<pubDate>Thu, 26 May 2011 09:54:05 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=742</guid>
		<description><![CDATA[This game was called &#8220;Game3&#8243; just because this is the 3rd XNA project I&#8217;ve opened on this computer, and that was the default name. I&#8217;ve put in somewhere between 500-900 hours into this project (schoolwork being mixed in there makes &#8230; <a href="http://www.olhovsky.com/2011/05/game3-post-mortem-or-how-i-learned-to-stop-worrying-and-love-development-outside-of-the-dbp-competition/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This game was called &#8220;Game3&#8243; just because this is the 3rd XNA project I&#8217;ve opened on this computer, and that was the default name.</p>
<p>I&#8217;ve put in somewhere between 500-900 hours into this project (schoolwork being mixed in there makes it hard to estimate), and I think that I&#8217;ve been very productive in that time. The project is now 8300 lines of code, in about 187 class files.</p>
<p>So, why didn&#8217;t I finish in time for <a href="http://www.dreambuildplay.com/">DBP</a>? Here are some of the mistakes I made:</p>
<ul>
<li>Overambitious project goals.</li>
<li>Picked wrong light rendering design for the design of this game.</li>
<li>Underestimated the complexity of implementing some design ideas, such as the terrain, and the lighting set up.</li>
<li>Focused too much on building clean, pretty code, instead of hacking together a finished game.</li>
<li>Spent too much time building the game engine, and too little time building the actual game logic.</li>
<li>Spent two weeks building <a title="The physics engine (made from scratch!)." href="http://www.olhovsky.com/2011/05/physics-engine/">my own physics engine</a> from scratch, instead of using an existing engine.</li>
</ul>
<p>Here&#8217;s a composite of a few screenshots of my Git commit history:</p>
<div id="attachment_744" class="wp-caption aligncenter" style="width: 81px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may26_commit_history.png"><img class="size-medium wp-image-744" title="may26_commit_history" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may26_commit_history-71x300.png" alt="" width="71" height="300" /></a><p class="wp-caption-text"> (Click to enlarge.)</p></div>
<p>I tried to choose a game concept that was as simple as possible, while still maintaining some of the key elements from my 100+ page outline of a much more complex game.</p>
<p>That said, I was still far too ambitious for a 3 month project. I think that any 3D game that can be competitive with a 2D game is going to take a lot of extra time to polish well. For example, I didn&#8217;t realize how much time triplanar normal mapping would take to get right. It&#8217;s simple in theory, but getting the slope angles just right, getting the transitions between texturing planes just right, mapping the normal maps onto the correct plane, etc, etc, all took a lot of extra time.</p>
<p>Before deciding to do this project in first person 3D, I read that many people avoid indie 3D games because creating the artwork takes so much longer (or they can&#8217;t do it themselves). As one example, it took me about 45 minutes to create the <a title="First enemy: Doll." href="http://www.olhovsky.com/2011/04/first-enemy-doll/">doll enemy</a> model (pretty quick, no?). I figured, well, I can create a 3D model of an enemy in ~45 minutes, so 3D artwork is not a big deal &#8212; I&#8217;ll just go make the next <a href="http://en.wikipedia.org/wiki/Halo:_Reach">Halo</a> now!</p>
<p>In reality, the artwork is no big deal. It&#8217;s really everything but the artwork that makes 3D much more work than 2D, especially from a first person perspective. When I say &#8220;artwork&#8221; I mean 3D models, textures, texture mapping, animations.</p>
<p>In a first person perspective, you can see thousands of meters into the distance, but also if the player looks straight down at the ground, since only a 1-2 meters are viewable, we expect to see a great deal of detail. Managing detail at close and far distances well is an order of magnitude harder than managing detail in a 2D game. In a 2D game, or even in a 3D game with a relatively fixed camera perspective (e.g. Starcraft or Diablo), you know how much geometry can be viewable in the worst case, and there&#8217;s much less detail scaling needed.</p>
<p>As an example of detail scaling, getting terrain detail to scale well in this game was done over the course of many weeks. Indeed, it&#8217;s still not perfect. If you&#8217;ve tried your hand at realtime 3D drawing, then you&#8217;ve probably done a terrain. However, you may not have encountered the mess of fading textures and specular/normal/emmissive maps between detail levels. I used geometry instancing for the distant chunks, which meant no lights in the distance in my lighting model. Things like this added up quickly.</p>
<p>I thought a bit about what the title of this post should be. A reference to <a href="http://en.wikipedia.org/wiki/Duke_Nukem_Forever#Development">Duke Nukem Forever</a> felt appropriate at first, until I realized that it&#8217;s probably not fair to compare my 3 months of development to 14 years of off-and-on DNF development. Hell, even if I am writing DNF-level vaporware, at least Duke Nukem Forever is finally being released, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/game3-post-mortem-or-how-i-learned-to-stop-worrying-and-love-development-outside-of-the-dbp-competition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Physics engine integrated, and sphere-terrain collision done.</title>
		<link>http://www.olhovsky.com/2011/05/physics-engine-integrated-and-sphere-terrain-collision-done/</link>
		<comments>http://www.olhovsky.com/2011/05/physics-engine-integrated-and-sphere-terrain-collision-done/#comments</comments>
		<pubDate>Tue, 17 May 2011 09:45:11 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=706</guid>
		<description><![CDATA[Terrain collision was a little harder than I thought it would be. This is owing to the fact that the terrain is a concave body, and many contacts are possible with a single sphere and the terrain. Contrast this with &#8230; <a href="http://www.olhovsky.com/2011/05/physics-engine-integrated-and-sphere-terrain-collision-done/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Terrain collision was a little harder than I thought it would be. This is owing to the fact that the terrain is a concave body, and many contacts are possible with a single sphere and the terrain. Contrast this with two convex bodies (which many physics engines use exclusively) where only a single contact point is possible, and that point is also the closest point between the two objects.</p>
<p>Anyways, terrain-sphere collision works now, and the new terrain engine is integrated into the game. Simulating 400 spheres on the PC takes only ~3ms per update (single threaded). This should make 400 spheres viable on the XBOX 360, which will have about 33ms per update on a CPU core dedicated to physics. This is about a 5-10x speed increase over the performace I was seeing with the default BEPU physics setup.</p>
<div id="attachment_711" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may17_physics_integrated1.png"><img class="size-large wp-image-711" title="may17_physics_integrated" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may17_physics_integrated1-1024x598.png" alt="Sphere-terrain collision." width="640" height="373" /></a><p class="wp-caption-text">Sphere-terrain collision.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/physics-engine-integrated-and-sphere-terrain-collision-done/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The physics engine (made from scratch!).</title>
		<link>http://www.olhovsky.com/2011/05/physics-engine/</link>
		<comments>http://www.olhovsky.com/2011/05/physics-engine/#comments</comments>
		<pubDate>Wed, 11 May 2011 20:35:50 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=688</guid>
		<description><![CDATA[In the last few days I wrote a physics engine from scratch using a technique that no other 3D XNA physics engine (that I know of) uses yet: Speculative contact continuous collision detection. I&#8217;ve been looking for a good physics &#8230; <a href="http://www.olhovsky.com/2011/05/physics-engine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the last few days I wrote a physics engine from scratch using a technique that no other 3D XNA physics engine (that I know of) uses yet: Speculative contact continuous collision detection.</p>
<div id="attachment_689" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may11_physics_engine_start.png"><img class="size-large wp-image-689" title="may11_physics_engine_start" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may11_physics_engine_start-1024x572.png" alt="350 spheres colliding against 4 intersecting planes." width="640" height="357" /></a><p class="wp-caption-text">The new physics engine in action: 350 spheres colliding against 4 intersecting planes.</p></div>
<p>I&#8217;ve been looking for a good physics engine for this game for a while now, and my favorite so far is <a href="http://bepu.squarespace.com/">BEPU</a>. If you need a physics engine for your game, BEPU is pretty awesome. They went open source just recently, and their simulation is extremely stable and pretty accurate. They support all sorts of constraints, and Norbo is constantly monitoring and responding to questions on the forum.</p>
<p>That said, my game idea relies on having potentially hundreds of spheres in the world at once, and with an entire single CPU core devoted to the physics on the XBOX (plus the physics management on the draw core) I was only able to simulate 20-30 spheres at a 20FPS physics update, and that was only if they were all reasonably spaced apart.</p>
<p>However, I don&#8217;t need the precision of BEPU, and for most spheres, I don&#8217;t care if they have accurate 3D angular momentum. BEPU also doesn&#8217;t exploit the properties of my game world, such as the fact that physically simulated objects are rarely on top of one-another. So, I decided to write my own engine, taking all of these special cases into account.</p>
<p><a href="http://www.wildbunny.co.uk/blog/2011/03/25/speculative-contacts-an-continuous-collision-engine-approach-part-1/">Paul Firth wrote a post about speculative contacts</a>, a continous collision detection approach to physics simulation.</p>
<p>Using this idea, I&#8217;ve created a simple CCD physics engine. While there are drawbacks to this approach, it&#8217;s suitable for my purposes, and remarkably stable with just one solver iteration. This together with the exploitation of the special case for physics in this game, should prove to be much more efficient.</p>
<p><iframe width="560" height="349" src="http://www.youtube.com/embed/bQyrVPWMC6c" frameborder="0" allowfullscreen></iframe></p>
<p>Above is a recording of the engine in action. Sphere and plane collisions are currently handled. This is 99% of the work for sphere-terrain collision, which is almost everything I need to add this into the game.</p>
<p><iframe width="560" height="349" src="http://www.youtube.com/embed/JvT2H1RmOas" frameborder="0" allowfullscreen></iframe></p>
<p>This physics engine already uses the same spatial partitioning approach used in the game (two grids which act as the bottom two levels of a complete quad-tree).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/physics-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Terrain changes (and the first video capture).</title>
		<link>http://www.olhovsky.com/2011/05/terrain-changes-and-the-first-video-capture/</link>
		<comments>http://www.olhovsky.com/2011/05/terrain-changes-and-the-first-video-capture/#comments</comments>
		<pubDate>Wed, 04 May 2011 21:27:33 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=668</guid>
		<description><![CDATA[If you&#8217;re like me then you&#8217;re tired of seeing the terrain, and you want to see the gameplay. Sure, I want to work on nothing but the gameplay at this point. However, the gameplay takes place at night &#8212; and &#8230; <a href="http://www.olhovsky.com/2011/05/terrain-changes-and-the-first-video-capture/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me then you&#8217;re tired of seeing the terrain, and you want to see the gameplay. Sure, I want to work on nothing but the gameplay at this point. However, the gameplay takes place at night &#8212; and nighttime scenes aren&#8217;t very fun without some lights. Lots of lights at 20 FPS wouldn&#8217;t be much fun either, so some optimizations were necessary.</p>
<p>I decided that only having ~30 lights visible at a time on the xbox wasn&#8217;t enough, so I spent yesterday implementing a new level of detail system. How many lights the XBOX will allow when everything is in the scene is to be determined, but for now I can estimate that about twice as many will be possible (50-60 point lights visible at once). That&#8217;s a lot more than you&#8217;d expect from a forward rendered game on the XBOX 360, typically.</p>
<p>&nbsp;</p>
<p><iframe width="640" height="390" src="http://www.youtube.com/embed/rQvQ02zl6hc" frameborder="0" allowfullscreen></iframe></p>
<p>&nbsp;</p>
<div id="attachment_669" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_optimizing_terrain.png"><img class="size-medium wp-image-669" title="may03_optimizing_terrain" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_optimizing_terrain-300x175.png" alt="" width="300" height="175" /></a><p class="wp-caption-text">Distant blocks now take up 1/4 space, and will be scaled up -- similar to a quad tree implementation.</p></div>
<div id="attachment_670" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_optimizing_terrain2.png"><img class="size-medium wp-image-670" title="may03_optimizing_terrain2" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_optimizing_terrain2-300x175.png" alt="" width="300" height="175" /></a><p class="wp-caption-text">1/4 size blocks are now scaled up.</p></div>
<div id="attachment_672" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may04_optimizing_terrain.png"><img class="size-medium wp-image-672" title="may04_optimizing_terrain" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may04_optimizing_terrain-300x175.png" alt="" width="300" height="175" /></a><p class="wp-caption-text">Color coded levels of detail.</p></div>
<div id="attachment_673" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may04_optimizing_terrain2.png"><img class="size-large wp-image-673" title="may04_optimizing_terrain2" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may04_optimizing_terrain2-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">Blocks have been slightly separated to make them visible.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/terrain-changes-and-the-first-video-capture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS2010 corruption woes and a new GPU.</title>
		<link>http://www.olhovsky.com/2011/05/vs2010-corruption-woes-and-a-new-gpu/</link>
		<comments>http://www.olhovsky.com/2011/05/vs2010-corruption-woes-and-a-new-gpu/#comments</comments>
		<pubDate>Tue, 03 May 2011 06:04:30 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=660</guid>
		<description><![CDATA[I bought a new GPU today, and after installing it and restarting, visual studio decided to stop working, producing random errors (e.g. &#8220;Unable to start program. Cannot find file specified.&#8221; when trying to run the project). After wasting an hour &#8230; <a href="http://www.olhovsky.com/2011/05/vs2010-corruption-woes-and-a-new-gpu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I bought a new GPU today, and after installing it and restarting, visual studio decided to stop working, producing random errors (e.g. &#8220;<a href="http://stackoverflow.com/questions/5864520/error-while-trying-to-run-project-unable-to-start-program-cannot-find-the-file">Unable to start program. Cannot find file specified</a>.&#8221; when trying to run the project). After wasting an hour trying to fix it, I resorted to using the VS Repair tool which did actually fix things. I decided to reduce the overclock on this machine just in case the corruption was related to that &#8212; though I doubt it, it&#8217;s better to be safe with only 41 days left &#8217;til the competition deadline.</p>
<p>Yesterday the game ran on this PC at a meager 20-35 FPS. Today it runs at well over 300 FPS thanks to the new GPU.</p>
<div id="attachment_661" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_300fps.png"><img src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/may03_300fps-1024x598.png" alt="" title="may03_300fps" width="640" height="373" class="size-large wp-image-661" /></a><p class="wp-caption-text">302 FPS on the new GPU.</p></div>
<p>Oh how much easier this development would be if I could just run the game on this PC&#8230;</p>
<p>Anyways, now that I have a new GPU; gameplay vids incoming!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/vs2010-corruption-woes-and-a-new-gpu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Status update: Point light stress testing.</title>
		<link>http://www.olhovsky.com/2011/05/status-update-point-light-stress-testing/</link>
		<comments>http://www.olhovsky.com/2011/05/status-update-point-light-stress-testing/#comments</comments>
		<pubDate>Mon, 02 May 2011 04:54:39 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[lighting]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=643</guid>
		<description><![CDATA[Yesterday I added over 1000 (one thousand) moving point lights to the terrain. On the PC this was fine. The scene partitioning used by my forward rendering setup uses a lot of CPU time though, so on the XBOX this &#8230; <a href="http://www.olhovsky.com/2011/05/status-update-point-light-stress-testing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I added over 1000 (one thousand) moving point lights to the terrain. On the PC this was fine. The scene partitioning used by my forward rendering setup uses a lot of CPU time though, so on the XBOX this performed abysmally &#8212; it took something like 10ms to update all of the point lights in the scene partitioner &#8212; not including calculating their positions. (And remember, we only have around 16-20ms per frame to do <em><strong>all</strong></em> updating.)</p>
<div id="attachment_644" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april30_point_light_stress_test1.png"><img class="size-large wp-image-644" title="april30_point_light_stress_test1" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april30_point_light_stress_test1-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">Point light stress testing.</p></div>
<div id="attachment_645" class="wp-caption alignleft" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april30_point_light_stress_test2.png"><img class="size-large wp-image-645" title="april30_point_light_stress_test2" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april30_point_light_stress_test2-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">Point light stress testing.</p></div>
<p>&nbsp;</p>
<p>Since this was so slow, and I want to associate a point light with most enemies, I&#8217;ve been optimizing the partitioning a bit without making any very drastic changes.</p>
<p>Since there&#8217;s only about a month left, I decided that the smart thing to do is just to reduce the size of the terrain, and reduce the number of lights, in order to get everything done. Once it&#8217;s all working, I&#8217;ll consider revising the partitioning system to support a larger world again, and add more lights.</p>
<p>Below is the current state of things:</p>
<div id="attachment_646" class="wp-caption alignleft" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights_and_physics.png"><img class="size-large wp-image-646" title="april01_point_lights_and_physics" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights_and_physics-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">Point light testing, and some spheres rolling around on the terrain, colliding with each other.</p></div>
<p>After optimizations, this runs at about twice the speed that it did yesterday.</p>
<p><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights2.png"><img class="aligncenter size-large wp-image-655" title="april01_point_lights2" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights2-1024x598.png" alt="" width="640" height="373" /></a></p>
<p>Struggling to get things working fast enough on the XBOX CPU (which provides me with roughly 10% of my PCs processing power) has been slowing me down a lot. Things that I keep expecting to be more than efficient enough, turn out to be twice as slow as what&#8217;s really feasible.</p>
<p><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights.png"><img class="aligncenter size-large wp-image-653" title="april01_point_lights" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/05/april01_point_lights-1024x598.png" alt="" width="640" height="373" /></a></p>
<p>The image above has only 270 point lights spread out across the terrain (the little blue particles, only about 30 are visible), but runs at about 65FPS on the XBOX, limited by the CPU. That should hopefully be enough for the state of the game at the competition deadline. Far more lights, and a much bigger world is possible &#8212; but it&#8217;s not looking like I&#8217;ll have time for more than this before June 14th.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/05/status-update-point-light-stress-testing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Slope based terrain texturing.</title>
		<link>http://www.olhovsky.com/2011/04/slope-based-terrain-texturing/</link>
		<comments>http://www.olhovsky.com/2011/04/slope-based-terrain-texturing/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 13:54:01 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[terrain]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=613</guid>
		<description><![CDATA[Today I worked on getting the terrain texturing to match the new procedurally created level from yesterday. In the image above, a dead grass texture is applied to flat portions of terrain, a green texture on the edges at intermediate &#8230; <a href="http://www.olhovsky.com/2011/04/slope-based-terrain-texturing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I worked on getting the terrain texturing to match the new <a title="Procedural level creation." href="http://www.olhovsky.com/2011/04/procedural-level-creation/">procedurally created level</a> from yesterday.</p>
<div id="attachment_614" class="wp-caption alignleft" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april20_slope_based_texturing.png"><img class="size-large wp-image-614" title="april20_slope_based_texturing" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april20_slope_based_texturing-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">Slope based texturing. 3 textures applied at different slopes.</p></div>
<p>In the image above, a dead grass texture is applied to flat portions of terrain, a green texture on the edges at intermediate slopes, and a (very stretched) rock texture is applied to the steep slopes.</p>
<p>The stretching of textures on the very steep slopes can be corrected by projecting the texture from a different plane. Currently all texture coordinates are produced by projecting the textures from the XZ plane. The steep slopes require projections from the XY and YZ planes though, so I&#8217;ll work on that tomorrow. Edit: <a title="Texturing steep terrain slopes." href="http://www.olhovsky.com/2011/04/texturing-steep-terrain-slopes/">texture projections for steep slopes</a> are now complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/04/slope-based-terrain-texturing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing terrain culling.</title>
		<link>http://www.olhovsky.com/2011/04/fighting-with-the-xbox-360-cpu/</link>
		<comments>http://www.olhovsky.com/2011/04/fighting-with-the-xbox-360-cpu/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 03:41:09 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[xbox]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=571</guid>
		<description><![CDATA[The code that culls terrain chunks was using a 3D bounding box vs camera frustum test for each terrain chunk, which was incredibly slow. On the XBOX 360 this was taking about 4ms for ~200 intersection tests. At 60FPS you &#8230; <a href="http://www.olhovsky.com/2011/04/fighting-with-the-xbox-360-cpu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The code that culls terrain chunks was using a 3D bounding box vs camera frustum test for each terrain chunk, which was incredibly slow. On the XBOX 360 this was taking about 4ms for ~200 intersection tests. At 60FPS you only get 16ms per frame to do everything, so terrain culling was taking up 25% of the CPU time.</p>
<p>I&#8217;ve refined the culling method to test blocks against an arbitrary polygon in 2D space.</p>
<div id="attachment_572" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april11_polygon_bound_culling.png"><img class="size-large wp-image-572" title="april11_polygon_bound_culling" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april11_polygon_bound_culling-1024x576.png" alt="" width="640" height="360" /></a><p class="wp-caption-text">Arbitrary polygon displayed with red lines. Terrain chunks that do not intersect this polygon are culled.</p></div>
<p>This method takes 0.5ms using a 6 vertex culling polygon &#8212; 8x faster than testing the camera frustum against terrain chunk bounding boxes. This in turn gives me enough room on the CPU to potentially quadruple the number of terrain chunks, and increase the number of lights, and the terrain detail.</p>
<p>This allows me to use the trapezoid of the camera frustum projected onto the ground plane to cull the terrain, like so:</p>
<div id="attachment_579" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/camera_frustum_project_onto_plane.jpg"><img class="size-full wp-image-579" title="camera_frustum_project_onto_plane" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/camera_frustum_project_onto_plane.jpg" alt="" width="640" height="480" /></a><p class="wp-caption-text">The camera frustum projected onto the terrain grid forms a trapezoid.</p></div>
<p>Image courtesy of <a href="http://www.gamedev.net/topic/531400-limiting-area-drawn-a-bit/">this forum post</a>.</p>
<p>This trapezoid however, is not enough. The shape needed is a projection of the entire frustum onto the terrain. I thought that wouldn&#8217;t be too hard, but it took ~12 hours to complete.</p>
<p>My method for finding the culling polygon desired, is to find the trapezoid above by intersecting the frustum rays against the terrain. Then project the near plane onto the terrain plane (good enough for our purposes).</p>
<p>Then take the resulting projected points and find the convex hull that surrounds them.</p>
<div id="attachment_582" class="wp-caption aligncenter" style="width: 708px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april13_terrain_culling_poly_illustration.png"><img class="size-full wp-image-582" title="april13_terrain_culling_poly_illustration" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april13_terrain_culling_poly_illustration.png" alt="" width="698" height="269" /></a><p class="wp-caption-text">On the left, a top down view of the camera frustum (projected onto the terrain). On the right, the convex hull resulting from the edges of this projection.</p></div>
<div id="attachment_583" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april13_terrain_frustum_poly_culling.png"><img class="size-large wp-image-583" title="april13_terrain_frustum_poly_culling" src="http://www.olhovsky.com/wp/wp-content/uploads/2011/04/april13_terrain_frustum_poly_culling-1024x598.png" alt="" width="640" height="373" /></a><p class="wp-caption-text">The red lines display the shape of the culling polygon produced from projecting the camera frustum onto the sea plane.</p></div>
<p>Although this took much longer than expected to implement, along the way I&#8217;ve implemented ray-terrain intersection testing, convex hull from point cloud creation, simple polygon point list winding (i.e. take a convex hull and produce the list of vertices in clockwise winding order), and point in polygon testing.</p>
<p>These tools will come in handy very soon, as monsters and more physics are introduced into the game.  For example, I can now compute a bounding polygon for a monster, instead of just using a bounding sphere/box.</p>
<p>Now that things are being drawn reasonably efficiently, I can finally start to implement some interesting game mechanics. Stay tuned for that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/04/fighting-with-the-xbox-360-cpu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dozens of point lights with forward rendering.</title>
		<link>http://www.olhovsky.com/2011/03/dozens-of-point-lights-with-forward-rendering/</link>
		<comments>http://www.olhovsky.com/2011/03/dozens-of-point-lights-with-forward-rendering/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 17:10:11 +0000</pubDate>
		<dc:creator>olhovsky</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[DBP2011]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[dream build play]]></category>
		<category><![CDATA[xbox]]></category>

		<guid isPermaLink="false">http://www.olhovsky.com/?p=526</guid>
		<description><![CDATA[I&#8217;ve spent the last few days working on spatial partitioning, object pooling code (and fighting with stackoverflow about it), and other necessary performance optimization code. Most AAA titles seem to support something like 5-6 dynamic lights. I&#8217;m sure you&#8217;ve noticed &#8230; <a href="http://www.olhovsky.com/2011/03/dozens-of-point-lights-with-forward-rendering/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent the last few days working on spatial partitioning, object pooling code (and <a href="http://stackoverflow.com/questions/5486654/allowing-iteration-without-generating-any-garbage/5487374">fighting with stackoverflow</a> about it), and other necessary performance optimization code.</p>
<p>Most AAA titles seem to support something like 5-6 dynamic lights. I&#8217;m sure you&#8217;ve noticed by now that this game takes place mostly in the dark, and I plan on making it darker still (if I can). Well placed lighting will play a big role in making things look interesting, as well as just being able to see your surroundings.</p>
<p><a href="http://jcoluna.wordpress.com/2011/02/07/xna-4-0-light-pre-pass-shedding-the-light/">Pre-pass</a> or fully <a href="http://www.catalinzima.com/tutorials/deferred-rendering-in-xna/">deferred rendering</a> would allow for many lights with little work, but these rendering schemes don&#8217;t support MSAA or, more importantly, transparent objects. Also, deferred lighting is not a very good fit for the XBOX, due to it&#8217;s 10MB EDRAM and predicated tiling, and it&#8217;s relatively low texture bandwidth. I did spend a little bit of time playing with <a href="http://jcoluna.wordpress.com/">J. Coluna&#8217;s</a> pre-pass rendering code on the XBOX a few days ago, but the lighting quality was very poor when used with the XBOX HDRBlendable format (which is 10 bits per channel plus 2 bits left over).</p>
<p>By partitioning the space into a grid and registering objects and terrain chunks into it, I can currently draw 30 point lights at once on the xbox (at 60 FPS). The CPU speed is the limitation so far, not the graphics card.</p>
<p>Of course, that is with just the terrain. Things will get a lot slower when I start adding trees and other objects.</p>
<p>And I haven&#8217;t mentioned shadows yet.</p>
<p>In order to be able to set the game in the dark atmosphere that I&#8217;m going for, I&#8217;ll want to have at least 20 point lights, though I might be able to get away with casting shadows from only 10 or so.</p>
<div id="attachment_527" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/03/march31_projectiles_and_point_lights.png"><img src="http://www.olhovsky.com/wp/wp-content/uploads/2011/03/march31_projectiles_and_point_lights-1024x405.png" alt="March 31 Projectiles and Point Lights" title="march31_projectiles_and_point_lights" width="640" height="253" class="size-large wp-image-527" /></a><p class="wp-caption-text">Dynamic point lights moving across the terrain.</p></div>
<p>I&#8217;ve starting writing some basic rigid body physics. I have projectiles working that can detect collision, but do not react to collisions appropriately yet. Actually the lights in the picture above are projectiles launched from the camera&#8217;s position.</p>
<p>I&#8217;ve also built a framework for making explosions of various types, complete with flying debris.</p>
<div id="attachment_528" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.olhovsky.com/wp/wp-content/uploads/2011/03/march-31-explosions.png"><img src="http://www.olhovsky.com/wp/wp-content/uploads/2011/03/march-31-explosions.png" alt="" title="march 31 explosions" width="600" height="299" class="size-full wp-image-528" /></a><p class="wp-caption-text">A couple of basic explosions with debris.</p></div>
<p>The explosion above uses a fairly flexible Explosion class that I wrote yesterday, so new explosions can easily be created with little code at this point. Most projectiles that the player can fire will need some sort of explosion, so recreating an explosion type effect will happen often. This could be used to display the destruction of a crate for example. Just replace the explosion particles with subtle smoke, and the debris with broken wood models. Since the explosion debris are projectiles themselves, they can have their own explosions, which can have their own debris, ad infinitum.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.olhovsky.com/2011/03/dozens-of-point-lights-with-forward-rendering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

