<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Miles Macklin</title>
	<atom:link href="http://mmack.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mmack.wordpress.com</link>
	<description>Code blog</description>
	<lastBuildDate>Mon, 28 Sep 2009 17:13:26 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='mmack.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/f1d53707f7d32f765ff95813f6f62cc7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Miles Macklin</title>
		<link>http://mmack.wordpress.com</link>
	</image>
			<item>
		<title>Trees (the green kind)</title>
		<link>http://mmack.wordpress.com/2009/09/28/trees-the-green-kind/</link>
		<comments>http://mmack.wordpress.com/2009/09/28/trees-the-green-kind/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 17:13:26 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=320</guid>
		<description><![CDATA[I&#8217;ve always had an interest in computer generated plants so I was pleased to read Self-organising tree models for image synthesis from Siggraph this year.
The paper basically pulls together a bunch of techniques that have been around for a while and uses them to generate some really good looking tree models.
Seeing as I&#8217;ve had a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=320&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve always had an interest in computer generated plants so I was pleased to read <a href="http://algorithmicbotany.org/papers/selforg.sig2009.html">Self-organising tree models for image synthesis</a> from Siggraph this year.</p>
<p>The paper basically pulls together a bunch of techniques that have been around for a while and uses them to generate some really good looking tree models.</p>
<p>Seeing as I&#8217;ve had a bit of time on my hands between Batman and before I start at LucasArts I decided to put together an implementation in OpenGL (being a games programmer I want realtime feedback).  </p>
<p>Some screenshots below and a Win32 executable available &#8211; <a href="http://mmacklin.dreamhosters.com/Plant.zip">Plant.zip</a></p>
<p><img src="http://mmack.files.wordpress.com/2009/09/tree_1.jpg?w=480&#038;h=480" alt="tree_1" title="tree_1" width="480" height="480" class="aligncenter size-full wp-image-323" /><br />
<img src="http://mmack.files.wordpress.com/2009/09/tree_2_bare.jpg?w=480&#038;h=480" alt="tree_2_bare" title="tree_2_bare" width="480" height="480" class="aligncenter size-full wp-image-325" /><br />
<img src="http://mmack.files.wordpress.com/2009/09/tree_2_leaves.jpg?w=480&#038;h=480" alt="tree_2_leaves" title="tree_2_leaves" width="480" height="480" class="aligncenter size-full wp-image-326" /></p>
<p>Some Notes:</p>
<p>I implemented both the space colonisation and shadow propagation methods.  The space colonisation is nice in that you can draw where the plant should grow by placing space samples with the mouse, this allows some pretty funky topiary but I found it difficult to grow convincing real-world plants with this method.  The demo only uses the shadow propagation method.</p>
<p>Creating the branch geometry from generalised cylinders requires generating a continuous coordinate frame along a curve without any twists or knots.  I used a parallel transport frame for this which worked out really nicely, these two papers describe the technique and the problem:</p>
<p><a href="http://www.cs.indiana.edu/pub/techreports/TR425.pdf">Parallel Transport Approach to Curve Framing</a><br />
<a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.8658">Quaternion Gauss Maps and Optimal Framings of Curves and Surfaces (1998) </a></p>
<p>Getting the lighting and leaf materials to look vaguely realistic took quite a lot of tweaking and I&#8217;m not totally happy with it.  Until I implemented self-shadowing on the trunk and leaves it looked very weird.  Also you need to account for the transmission you get through the leaves when looking toward the light:</p>
<p><img src="http://mmack.files.wordpress.com/2009/09/tree_inside.jpg?w=480&#038;h=470" alt="tree_inside" title="tree_inside" width="480" height="470" class="aligncenter size-full wp-image-327" /></p>
<p>There is a nice <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch04.html">article</a> in GPU Gems 3 on how SpeedTree do this.</p>
<p>The leaves are normal mapped with a simple Phong specular, I messed about with various modified diffuse models like half-Lambert but eventually just went with standard Lambert.  It would be interesting to use a more sophisticated ambient term.</p>
<p>Still a lot of scope for performance optimisation, the leaves are alpha-tested right now so it&#8217;s doing loads of redundant fragment shader work (something like <a href="http://www.humus.name/index.php?page=Cool&amp;ID=8">Emil Persson&#8217;s particle trimmer</a> would be useful here).</p>
<p>If you want to take a look at the source code drop me an <a href="http://mmack.wordpress.com/about/">email</a>.</p>
<p>Known issues:</p>
<p>On my NVIDIA card when the vert count is &gt; 10^6 it runs like a dog, I need to break it up into smaller vertex buffers.</p>
<p>Some ATI mobile drivers don&#8217;t like the variable number of shadow mapping samples.  If that&#8217;s your card then I recommend hacking the shaders to disable it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=320&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/09/28/trees-the-green-kind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/09/tree_1.jpg" medium="image">
			<media:title type="html">tree_1</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/09/tree_2_bare.jpg" medium="image">
			<media:title type="html">tree_2_bare</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/09/tree_2_leaves.jpg" medium="image">
			<media:title type="html">tree_2_leaves</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/09/tree_inside.jpg" medium="image">
			<media:title type="html">tree_inside</media:title>
		</media:content>
	</item>
		<item>
		<title>Atomic float+</title>
		<link>http://mmack.wordpress.com/2009/08/19/atomic-float/</link>
		<comments>http://mmack.wordpress.com/2009/08/19/atomic-float/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 12:50:56 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=305</guid>
		<description><![CDATA[No hardware I know of has atomic floating point operations but here&#8217;s a handy little code snippet from Matt Pharr over on the PBRT mailing list which emulates the same functionality using an atomic compare and swap:
inline float AtomicAdd(volatile float *val, float delta) {
     union bits { float f; int32_t i; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=305&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>No hardware I know of has atomic floating point operations but here&#8217;s a handy little code snippet from Matt Pharr over on the <a href="http://groups.google.com/group/pbrt">PBRT mailing list</a> which emulates the same functionality using an atomic compare and swap:</p>
<pre class="brush: cpp;">inline float AtomicAdd(volatile float *val, float delta) {
     union bits { float f; int32_t i; };
     bits oldVal, newVal;
     do {
         oldVal.f = *val;
         newVal.f = oldVal.f + delta;
     } while (AtomicCompareAndSwap(*((AtomicInt32 *)val),
         newVal.i, oldVal.i) != oldVal.i);
     return newVal.f;
}
</pre>
<p>In unrelated news, I&#8217;ve taken a job at LucasArts which I&#8217;ll be starting soon, sad to say goodbye to Rocksteady they&#8217;re a great company to work for and I&#8217;ll miss the team there.</p>
<p>Looking forward to San Francisco though, 12 hours closer to my home town (Auckland, New Zealand) and maybe now I can finally get along to Siggraph or GDC.  If anyone has some advice on where to live there please let me know!</p>
<p>Also a few weeks in between jobs so hopefully time to write some code and finish off all the tourist activities we never got around to in London.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=305&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/08/19/atomic-float/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
		<item>
		<title>Fin!</title>
		<link>http://mmack.wordpress.com/2009/08/14/fin/</link>
		<comments>http://mmack.wordpress.com/2009/08/14/fin/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 12:49:11 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=297</guid>
		<description><![CDATA[Batman: Arkham Asylum is finished and the demo is up on PSN and Xbox Live.  I was pretty much responsible for the PS3 version on the code side so anything wrong with it is ultimately my fault.  As any PS3 engineer working on a cross platform title will tell you there is always [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=297&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="www.batmanarkhamasylum.com">Batman: Arkham Asylum</a> is finished and the demo is up on PSN and Xbox Live.  I was pretty much responsible for the PS3 version on the code side so anything wrong with it is ultimately my fault.  As any PS3 engineer working on a cross platform title will tell you there is always the fear of the &#8217;side by side comparison&#8217;.  This popped up pretty quickly after the demo was released:</p>
<p><a href="http://www.eurogamer.net/articles/digitalfoundry-batman-demo-showdown-blog-entry">http://www.eurogamer.net/articles/digitalfoundry-batman-demo-showdown-blog-entry</a></p>
<p>The article is quite accurate (unlike some of the comments) and TBH it was as positive as I could have hoped for.</p>
<p>Generally the game has been getting a good <a href="http://img229.imageshack.us/img229/8589/batmanaagireview.jpg">reception </a>which is great to see as Batman games have a proud tradition of being complete rubbish.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/297/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=297&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/08/14/fin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
		<item>
		<title>Tim Sweeney&#8217;s HPG talk</title>
		<link>http://mmack.wordpress.com/2009/08/14/tim-sweeneys-hpg-talk/</link>
		<comments>http://mmack.wordpress.com/2009/08/14/tim-sweeneys-hpg-talk/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 12:14:37 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=293</guid>
		<description><![CDATA[This link was going round our office, a discussion over at Lambda the Ultimate regarding Tim Sweeney&#8217;s HPG talk.
http://lambda-the-ultimate.org/node/3560
Tim chimes in a bit further down in the comments.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=293&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This link was going round our office, a discussion over at Lambda the Ultimate regarding Tim Sweeney&#8217;s HPG talk.</p>
<p><a href="http://lambda-the-ultimate.org/node/3560">http://lambda-the-ultimate.org/node/3560</a></p>
<p>Tim chimes in a bit further down in the comments.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/293/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=293&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/08/14/tim-sweeneys-hpg-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
		<item>
		<title>Handy hints for Bovine occlusion</title>
		<link>http://mmack.wordpress.com/2009/07/24/handy-hints-for-bovine-occlusion/</link>
		<comments>http://mmack.wordpress.com/2009/07/24/handy-hints-for-bovine-occlusion/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:42:55 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=289</guid>
		<description><![CDATA[Code517E recently  reminded me of a site I&#8217;ve used before when looking up form factors for various geometric configurations.
One I had missed the first time though is the differential element on ceiling, floor or wall to cow.
http://www.me.utexas.edu/~howell/sectionb/B-68.html
Very handy if you&#8217;re writing a farmyard simulator I&#8217;m sure.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=289&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Code517E <a href="http://c0de517e.blogspot.com/2009/07/analytic-diffuse-shading.html">recently </a> reminded me of a site I&#8217;ve used before when looking up form factors for various geometric configurations.</p>
<p>One I had missed the first time though is the differential element on ceiling, floor or wall to cow.</p>
<p><a href="http://www.me.utexas.edu/~howell/sectionb/B-68.html">http://www.me.utexas.edu/~howell/sectionb/B-68.html</a></p>
<p>Very handy if you&#8217;re writing a farmyard simulator I&#8217;m sure.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=289&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/07/24/handy-hints-for-bovine-occlusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
		<item>
		<title>Particle lighting</title>
		<link>http://mmack.wordpress.com/2009/06/15/particle-lighting/</link>
		<comments>http://mmack.wordpress.com/2009/06/15/particle-lighting/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 22:39:50 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=278</guid>
		<description><![CDATA[I put together an implementation of the particle shadowing technique NVIDIA showed off a while ago.  My original intention was to do a survey of particle lighting techniques, in the end I just tried out two different methods that I thought sounded promising.
The first was the one ATI used in the Ruby White Out [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=278&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I put together an implementation of the particle shadowing technique NVIDIA <a href="http://www.youtube.com/watch?v=xh2q_p6hQEo">showed off</a> a while ago.  My original intention was to do a survey of particle lighting techniques, in the end I just tried out two different methods that I thought sounded promising.</p>
<p>The first was the one ATI used in the Ruby White Out demo, the best take away from it is that they write out the min distance, max distance and density in one pass.  You can do this by setting your RGB blend mode to GL_MIN, your alpha blend mode to GL_ADD and writing out r=z, g=1-z, b=0, a=density for each particle (you can reconstruct the max depth from min(1-z), think of it as the minimum distance from an end point).  Here&#8217;s a screen:</p>
<p><img src="http://mmack.files.wordpress.com/2009/06/smoke2.jpg?w=510&#038;h=309" alt="smoke2" title="smoke2" width="510" height="309" class="aligncenter size-full wp-image-281" /></p>
<p>The technique needs a bit of fudging to look OK.  Blur the depths, add some smoothing functions, it only works for mostly convex objects, good for amorphous blobs (clouds maybe).  Performance wise it is probably the best candidate for current-gen consoles.<br />
<a href="http://ati.amd.com/developer/gdc/2007/ArtAndTechnologyOfWhiteout(Siggraph07).pdf"><br />
http://ati.amd.com/developer/gdc/2007/ArtAndTechnologyOfWhiteout(Siggraph07).pdf</a></p>
<p>IMO the NVIDIA technique is much nicer visually, it gives you fairly accurate self shadowing which looks great but is considerably more expensive.  I won&#8217;t go into the implementation details too much as the paper does a pretty good job at describing it.<br />
<a href="http://developer.download.nvidia.com/compute/cuda/sdk/website/projects/smokeParticles/doc/smokeParticles.pdf">http://developer.download.nvidia.com/compute/cuda/sdk/website/projects/smokeParticles/doc/smokeParticles.pdf</a></p>
<p>The Nvidia demo uses 32k particles and 32 slices but you can get pretty decent results with much less.  Here&#8217;s a pic of my implementation, this is running on my trusty 7600 with 1000 particles and 10 slices through the volume:</p>
<p><img src="http://mmack.files.wordpress.com/2009/06/smoke1.jpg?w=510&#038;h=337" alt="smoke1" title="smoke1" width="510" height="337" class="aligncenter size-full wp-image-279" /></p>
<p>Unfortunately you need quite a lot of quite transparent particles otherwise there are noticeable artifacts as particles change order and end up in different slices.  You can improve this by using a non-linear distribution of slices so that you use more slices up front (which works nicely because the extinction for light in participating media is exponential).</p>
<p>Looking forward to tackling some surface shaders next.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=278&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/06/15/particle-lighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/06/smoke2.jpg" medium="image">
			<media:title type="html">smoke2</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/06/smoke1.jpg" medium="image">
			<media:title type="html">smoke1</media:title>
		</media:content>
	</item>
		<item>
		<title>Code charity</title>
		<link>http://mmack.wordpress.com/2009/04/01/code-charity/</link>
		<comments>http://mmack.wordpress.com/2009/04/01/code-charity/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 23:11:17 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=240</guid>
		<description><![CDATA[A friend just sent me this:
http://playpower.org/
It&#8217;s a non-profit organisation with the goal of developing educational games for developing countries that run on 8bit NES hardware.  The old Nintedo chips are now patent-free and clones are very common:

They&#8217;re trying to recruit programmers with a social conscience, I&#8217;m not old-school enough to know 8bit assembly but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=240&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A friend just sent me this:</p>
<p><a href="http://playpower.org/">http://playpower.org/</a></p>
<p>It&#8217;s a non-profit organisation with the goal of developing educational games for developing countries that run on 8bit NES hardware.  The old Nintedo chips are now patent-free and clones are very common:</p>
<p><a href="http://picasaweb.google.co.in/dereklomas/TVComputer"><img src="http://mmack.files.wordpress.com/2009/03/nes.jpg?w=509&#038;h=382" alt="nes" title="nes" width="509" height="382" class="aligncenter size-full wp-image-241" /></a></p>
<p>They&#8217;re trying to recruit programmers with a social conscience, I&#8217;m not old-school enough to know 8bit assembly but then I wouldn&#8217;t mind learning.. who needs GPUs anyway!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=240&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/04/01/code-charity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/03/nes.jpg" medium="image">
			<media:title type="html">nes</media:title>
		</media:content>
	</item>
		<item>
		<title>Red balls</title>
		<link>http://mmack.wordpress.com/2009/04/01/red-balls/</link>
		<comments>http://mmack.wordpress.com/2009/04/01/red-balls/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 23:00:13 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=245</guid>
		<description><![CDATA[A small update on my global illumination renderer, I&#8217;ve ported the radiance transfer to the GPU. It was fairly straight forward as my CPU tree structure was already set up for easy GPU traversal, basically just a matter of converting array offsets into texture coordinates and packing into an indices texture.
The hardest part is of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=245&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A small update on my global illumination renderer, I&#8217;ve ported the radiance transfer to the GPU. It was fairly straight forward as my CPU tree structure was already set up for easy GPU traversal, basically just a matter of converting array offsets into texture coordinates and packing into an indices texture.</p>
<p>The hardest part is of course wrangling OpenGL to do what you want and give you a proper error message.  This site is easily the best starting point I found for GPGPU stuff:<br />
<a href="http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/tutorial.html"><br />
http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/tutorial.html</a></p>
<p>So here&#8217;s an image, there are 7850 surfels, it runs about 20ms on my old school NVidia 7600, so it&#8217;s still at least an order of magnitude or two slower than you would need for typical game scenes.  But besides that it&#8217;s fun to pull area lights around in real time.</p>
<p><img src="http://mmack.files.wordpress.com/2009/04/balls2.jpg?w=506&#038;h=508" alt="balls2" title="balls2" width="506" height="508" class="aligncenter size-full wp-image-249" /></p>
<p>Not as much colour bleeding as you might expect, there is some but it is subtle.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=245&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/04/01/red-balls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>

		<media:content url="http://mmack.files.wordpress.com/2009/04/balls2.jpg" medium="image">
			<media:title type="html">balls2</media:title>
		</media:content>
	</item>
		<item>
		<title>Tree traversals</title>
		<link>http://mmack.wordpress.com/2009/02/22/tree-traversals/</link>
		<comments>http://mmack.wordpress.com/2009/02/22/tree-traversals/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 21:37:27 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=235</guid>
		<description><![CDATA[I changed my surfel renderer over to use a pre-order traversal layout for the nodes, this generally gives better cache utilisation and I did see a small speed up from using it.  The layout is quite nice because to traverse your tree you just linearly iterate over your array and whenever you find a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=235&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I changed my surfel renderer over to use a pre-order traversal layout for the nodes, this generally gives better cache utilisation and I did see a small speed up from using it.  The layout is quite nice because to traverse your tree you just linearly iterate over your array and whenever you find a subtree you want to skip you just increment your node pointer by the size of that subtree (which is precomputed, see Real Time Collision Detection 6.6.2).</p>
<p>The best optimisation though comes from compacting the size of the surfel data, which again improves the cache performance.  As some parts of the traversal don&#8217;t need all of the surfel data it seems to make sense to split things out, for instance to store the hierarchy information and the area seperately from the colour/irradiance information.</p>
<p>In fact it seems like when generalised, this idea leads you to the <a href="http://software.intel.com/en-us/articles/how-to-manipulate-data-structure-to-optimize-memory-use-on-32-bit-intel-architecture/">structure of arrays</a> (SOA) layout, which essentially provides the finest grained breakdown where you only pull into the cache what you use and for all the nodes that you skip over there is no added cost.</p>
<p>I haven&#8217;t done any timings to see how much of a win this would actually be, mainly because dealing with SOA data is so damn cumbersome.</p>
<p>It definitely seems like something you should do after you&#8217;ve done all your hierarchy building and node shuffling which is just so much more intuitive with structures.  Then you can just &#8216;bake&#8217; it down to SOA format and throw it at the GPU/SIMD.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=235&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/02/22/tree-traversals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
		<item>
		<title>PBRT</title>
		<link>http://mmack.wordpress.com/2009/02/22/pbrt/</link>
		<comments>http://mmack.wordpress.com/2009/02/22/pbrt/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 20:25:55 +0000</pubDate>
		<dc:creator>mmack</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mmack.wordpress.com/?p=232</guid>
		<description><![CDATA[I just bought a copy of Physically Based Rendering, I&#8217;ve been meaning to get one for ages as it&#8217;s often recommended and I thought it might be useful given my recent interest in global illumination. I&#8217;m also hoping to get a more formal background in rendering rather than the hacktastic world of real time.
The subjects [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=232&subd=mmack&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just bought a copy of <a href="http://www.pbrt.org/">Physically Based Rendering</a>, I&#8217;ve been meaning to get one for ages as it&#8217;s often recommended and I thought it might be useful given my recent interest in global illumination. I&#8217;m also hoping to get a more formal background in rendering rather than the hacktastic world of real time.</p>
<p>The subjects covered are broad and it&#8217;s very readable.  It&#8217;s my first exposure to <a href="http://en.wikipedia.org/wiki/Literate_programming">literate programming</a>, where essentially the book describes and contains the full implementation of a program.  In fact the source code for their renderer is generated (tangled) from the definition of the book before compilation.</p>
<p>The only problem is the amount it weighs, I like to read on the tube but 1000 page hard backs aren&#8217;t exactly light reading.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mmack.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mmack.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mmack.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mmack.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mmack.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mmack.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mmack.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mmack.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mmack.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mmack.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mmack.wordpress.com&blog=551482&post=232&subd=mmack&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mmack.wordpress.com/2009/02/22/pbrt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7a2afa150679090614485574c0368582?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mmack</media:title>
		</media:content>
	</item>
	</channel>
</rss>