<?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>MikeCann.co.uk &#187; Particles - MikeCann.co.uk - mikey see, mikey do!</title>
	<atom:link href="http://mikecann.co.uk/tag/particles/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikecann.co.uk</link>
	<description>mikey see, mikey do!</description>
	<lastBuildDate>Sat, 28 Jan 2012 13:10:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Hxaria, Infinite Terrain [HaXe, WebGL,dat.GUI]</title>
		<link>http://mikecann.co.uk/personal-project/hxaria-infinite-terrain-haxe-webgldat-gui/</link>
		<comments>http://mikecann.co.uk/personal-project/hxaria-infinite-terrain-haxe-webgldat-gui/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 14:19:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GLSL]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[Hxaria]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Personal Projects]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[terraria]]></category>
		<category><![CDATA[tilemaps]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1790</guid>
		<description><![CDATA[So I have been working on my &#8220;Terraria like Terrain&#8221; project &#8220;Hxaria&#8221; again. Following on from the last post, I have now made it so that each particle can have its texture changed. This completes the functionality required to render each tile as a point sprite, as talked about in my previous post. The way [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/11/header.jpg"><img class="alignnone size-full wp-image-1792" title="header" src="http://mikecann.co.uk/wp-content/uploads/2011/11/header.jpg" alt="" width="700" height="416" /></a></p>
<p>So I have been working on my &#8220;<a href="http://mikecann.co.uk/personal-project/hxaria-terraria-like-terrain-in-haxe-and-webgl/">Terraria like Terrain</a>&#8221; project &#8220;Hxaria&#8221; again.</p>
<p>Following on from the last post, I have now made it so that each particle can have its texture changed. This completes the functionality required to render each tile as a point sprite, as talked about in my<a href="http://mikecann.co.uk/personal-project/hxaria-terraria-like-terrain-in-haxe-and-webgl/"> previous post</a>.</p>
<p>The way it works is that the entire world is recorded in a 2&#215;2 array Tilemap. This 2&#215;2 array holds a single Tile object for every single tile in the world:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="actionscript3" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="kw4">class</span> Tile</div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw2">var</span> <span class="kw7">x</span> <span class="sy0">:</span> Int<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw2">var</span> <span class="kw7">y</span> <span class="sy0">:</span> Int<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw2">var</span> <span class="kw7">type</span> <span class="sy0">:</span> Int<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw1">new</span><span class="br0">&#40;</span><span class="kw7">x</span><span class="sy0">:</span>Int<span class="sy0">,</span> <span class="kw7">y</span><span class="sy0">:</span>Int<span class="sy0">,</span> <span class="kw7">type</span><span class="sy0">:</span>Int<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">this</span><span class="sy0">.</span><span class="kw7">x</span> = <span class="kw7">x</span><span class="sy0">;</span> <span class="kw1">this</span><span class="sy0">.</span><span class="kw7">y</span> = <span class="kw7">y</span><span class="sy0">;</span> <span class="kw1">this</span><span class="sy0">.</span><span class="kw7">type</span> = <span class="kw7">type</span><span class="sy0">;</span> <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></div></div>
<p>&nbsp;</p>
<p>When the TileRenderer needs to render it asks this Tilemap for a Tile that represents that screen coordinate, the Tilemap then offsets the position due to the camera movement and returns a tile. So it looks something like:</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/11/tm.png"><img class="alignnone size-full wp-image-1795" title="tm" src="http://mikecann.co.uk/wp-content/uploads/2011/11/tm.png" alt="" width="600" height="357" /></a></p>
<p>The tile type is then passed to the shader in attribute buffers per point sprite / tile along with all the tiles which are stored on a single texture:</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/11/tilescompressed.png"><img class="alignnone size-full wp-image-1803" title="tilescompressed" src="http://mikecann.co.uk/wp-content/uploads/2011/11/tilescompressed.png" alt="" width="256" height="352" /></a></p>
<p>The shader then performs the neccessary calculations to work out what the UV coordinate in the texture. The Vertex Shader:</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="glsl" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> amplitude<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> tileSize<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> texTilesWide<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> texTilesHigh<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> invTexTilesWide<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> invTexTilesHigh<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">attribute</span> <span class="kw3">float</span> size<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">attribute</span> <span class="kw3">vec3</span> customColor<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">attribute</span> <span class="kw3">float</span> tileType<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">varying</span> <span class="kw3">vec3</span> vColor<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">varying</span> <span class="kw3">vec2</span> vTilePos<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw3">void</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">	vColor <span class="sy0">=</span> customColor<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw3">float</span> t <span class="sy0">=</span> <span class="kw5">floor</span><span class="br0">&#40;</span>tileType<span class="sy0">/</span>texTilesWide<span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	vTilePos <span class="sy0">=</span> <span class="kw3">vec2</span><span class="br0">&#40;</span>tileType<span class="sy0">-</span><span class="br0">&#40;</span>t<span class="sy0">*</span>texTilesWide<span class="br0">&#41;</span><span class="sy0">,</span> t<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// +(.5/tileSize)</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw6">gl_PointSize</span> <span class="sy0">=</span> size<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw6">gl_Position</span> <span class="sy0">=</span> projectionMatrix <span class="sy0">*</span> modelViewMatrix <span class="sy0">*</span> <span class="kw3">vec4</span><span class="br0">&#40;</span> position<span class="sy0">,</span> 1<span class="sy0">.</span>0 <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></div></div>
<p>&nbsp;</p>
<p>And the Fragment Shader:</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="glsl" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">vec3</span> color<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">sampler2D</span> texture<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> invTexTilesWide<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">uniform</span> <span class="kw3">float</span> invTexTilesHigh<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">varying</span> <span class="kw3">vec3</span> vColor<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="kw2">varying</span> <span class="kw3">vec2</span> vTilePos<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw3">void</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">	<span class="kw3">vec2</span> uv <span class="sy0">=</span> <span class="kw3">vec2</span><span class="br0">&#40;</span> <span class="kw6">gl_PointCoord</span><span class="sy0">.</span><span class="me1">x</span><span class="sy0">*</span>invTexTilesWide <span class="sy0">+</span> invTexTilesWide<span class="sy0">*</span>vTilePos<span class="sy0">.</span><span class="me1">x</span><span class="sy0">,</span> <span class="kw6">gl_PointCoord</span><span class="sy0">.</span><span class="me1">y</span><span class="sy0">*</span>invTexTilesHigh <span class="sy0">+</span> invTexTilesHigh<span class="sy0">*</span>vTilePos<span class="sy0">.</span><span class="me1">y</span><span class="br0">&#41;</span><span class="sy0">;</span>	</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw6">gl_FragColor</span> <span class="sy0">=</span> <span class="kw5">texture2D</span><span class="br0">&#40;</span> texture<span class="sy0">,</span> uv <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></div></div>
<p>So it works in a way very much like a raster engine. You only have to render as many particles as the screen can contain.</p>
<p>If the screen area moves beyond the extent of the Tilemap then more tiles are randomly generated:</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/11/22222.png"><img class="alignnone size-full wp-image-1796" title="22222" src="http://mikecann.co.uk/wp-content/uploads/2011/11/22222.png" alt="" width="515" height="335" /></a></p>
<p>The new tiles are randomly selected from 4 different types, Dirt, Gold, Diamonds and Rock. I have added some controls to the demo that allow you to tweak these values to demonstrate the random tile generation:</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/11/Shot_041.png"><img class="alignnone size-full wp-image-1797" title="Shot_04" src="http://mikecann.co.uk/wp-content/uploads/2011/11/Shot_041.png" alt="" width="254" height="168" /></a></p>
<p>The UI may look familiar to people that have seen any experiments anyone who has worked with Three.js before, its the very popular <a href="http://code.google.com/p/dat-gui/">dat.GUI</a>. Its a really simple library written in javascript for creating controls that can be used to tweak experiments, perfect for me!</p>
<p>To get dat.GUI to work with haxe, I used the awesome <a href="http://www.google.co.uk/url?sa=t&amp;rct=j&amp;q=haxe%20externs&amp;source=web&amp;cd=1&amp;ved=0CBwQFjAA&amp;url=http%3A%2F%2Fhaxe.org%2Fdoc%2Fjs%2Fexterns&amp;ei=Gu_QTvK8IYP4sgbo15TzDA&amp;usg=AFQjCNEQvrXVfGjjQNO-yHhZ6HRTKlcmYw">Extern feature of HaXe</a>. This means that all I have to do is provide a stub interface to dat.GUI rather than a full implementation in haXe. This is great as it allows me to rapidly begin to use the library but also have the type safety of HaXe. It didnt take long to stub out the bits of the library I needed in an extern:</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="actionscript3" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="kw4">package</span> dat<span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* ...</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* @author Mike Cann</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">extern <span class="kw4">class</span> GUI</div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw1">new</span><span class="br0">&#40;</span>options<span class="sy0">:</span>Dynamic<span class="br0">&#41;</span> <span class="sy0">:</span> Void<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw7">add</span><span class="br0">&#40;</span>options<span class="sy0">:</span>Dynamic<span class="sy0">,</span> <span class="kw7">name</span><span class="sy0">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span class="kw5">String</span></a><span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw7">name</span><span class="br0">&#40;</span><span class="kw7">value</span><span class="sy0">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span class="kw5">String</span></a><span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw7">min</span><span class="br0">&#40;</span><span class="kw7">value</span><span class="sy0">:</span>Float<span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw7">max</span><span class="br0">&#40;</span><span class="kw7">value</span><span class="sy0">:</span>Float<span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> step<span class="br0">&#40;</span><span class="kw7">value</span><span class="sy0">:</span>Float<span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> onFinishChange<span class="br0">&#40;</span>f<span class="sy0">:</span>Void <span class="sy0">-&gt;</span> Void<span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw1">public</span> <span class="kw3">function</span> listen<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">:</span> GUI<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></div></div>
<p>Then I used it like:</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="actionscript3" style="font-family:monospace;"><span class="kw4">package</span> <span class="sy0">;</span>
<span class="kw1">import</span> dat<span class="sy0">.</span>GUI<span class="sy0">;</span>
&nbsp;
<span class="coMULTI">/**
 * ...
 * @author
 */</span>
&nbsp;
<span class="kw4">class</span> GUIManager
<span class="br0">&#123;</span>
	<span class="kw1">public</span> <span class="kw2">var</span> goldChance <span class="sy0">:</span> Float<span class="sy0">;</span>
	<span class="kw1">public</span> <span class="kw2">var</span> rockChance <span class="sy0">:</span> Float<span class="sy0">;</span>
	<span class="kw1">public</span> <span class="kw2">var</span> diamondsChance <span class="sy0">:</span> Float<span class="sy0">;</span>
	<span class="kw1">public</span> <span class="kw2">var</span> mapWidth <span class="sy0">:</span> Int<span class="sy0">;</span>
	<span class="kw1">public</span> <span class="kw2">var</span> mapHeight <span class="sy0">:</span> Int<span class="sy0">;</span>
&nbsp;
	<span class="kw1">private</span> <span class="kw2">var</span> gui <span class="sy0">:</span> GUI<span class="sy0">;</span>
	<span class="kw1">private</span> <span class="kw2">var</span> game <span class="sy0">:</span> Game<span class="sy0">;</span>
&nbsp;
	<span class="kw1">public</span> <span class="kw3">function</span> <span class="kw1">new</span><span class="br0">&#40;</span>game<span class="sy0">:</span>Game<span class="br0">&#41;</span>
	<span class="br0">&#123;</span>
		<span class="kw1">this</span><span class="sy0">.</span>game = game<span class="sy0">;</span>
&nbsp;
		gui = <span class="kw1">new</span> GUI<span class="br0">&#40;</span> <span class="br0">&#123;</span> <span class="kw7">height</span> <span class="sy0">:</span> 5 <span class="sy0">*</span> 32 <span class="sy0">-</span> 1 <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
		goldChance = game<span class="sy0">.</span>tilemap<span class="sy0">.</span>goldSpawnChance<span class="sy0">;</span>
		rockChance = game<span class="sy0">.</span>tilemap<span class="sy0">.</span>rockSpawnChance<span class="sy0">;</span>
		diamondsChance = game<span class="sy0">.</span>tilemap<span class="sy0">.</span>diamondsSpawnChance<span class="sy0">;</span>
		game<span class="sy0">.</span>tilemap<span class="sy0">.</span>mapResized = onTilemapResized<span class="sy0">;</span>
		mapWidth = <span class="nu0">0</span><span class="sy0">;</span>
		mapHeight = <span class="nu0">0</span><span class="sy0">;</span>
&nbsp;
		gui<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <span class="st0">'goldChance'</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">name</span><span class="br0">&#40;</span><span class="st0">&quot;Gold&quot;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">min</span><span class="br0">&#40;</span>0<span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">max</span><span class="br0">&#40;</span>1<span class="br0">&#41;</span><span class="sy0">.</span>step<span class="br0">&#40;</span>0<span class="sy0">.</span>001<span class="br0">&#41;</span><span class="sy0">.</span>onFinishChange<span class="br0">&#40;</span><span class="kw3">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> game<span class="sy0">.</span>tilemap<span class="sy0">.</span>goldSpawnChance = goldChance<span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
		gui<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <span class="st0">'rockChance'</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">name</span><span class="br0">&#40;</span><span class="st0">&quot;Rock&quot;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">min</span><span class="br0">&#40;</span>0<span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">max</span><span class="br0">&#40;</span>1<span class="br0">&#41;</span><span class="sy0">.</span>step<span class="br0">&#40;</span>0<span class="sy0">.</span>001<span class="br0">&#41;</span><span class="sy0">.</span>onFinishChange<span class="br0">&#40;</span><span class="kw3">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> game<span class="sy0">.</span>tilemap<span class="sy0">.</span>rockSpawnChance = rockChance<span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
		gui<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <span class="st0">'diamondsChance'</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">name</span><span class="br0">&#40;</span><span class="st0">&quot;Diamond&quot;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">min</span><span class="br0">&#40;</span>0<span class="br0">&#41;</span><span class="sy0">.</span><span class="kw7">max</span><span class="br0">&#40;</span>1<span class="br0">&#41;</span><span class="sy0">.</span>step<span class="br0">&#40;</span>0<span class="sy0">.</span>001<span class="br0">&#41;</span><span class="sy0">.</span>onFinishChange<span class="br0">&#40;</span><span class="kw3">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> game<span class="sy0">.</span>tilemap<span class="sy0">.</span>diamondsSpawnChance = diamondsChance<span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
		gui<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <span class="st0">'mapWidth'</span><span class="br0">&#41;</span><span class="sy0">.</span>listen<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
		gui<span class="sy0">.</span><span class="kw7">add</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <span class="st0">'mapHeight'</span><span class="br0">&#41;</span><span class="sy0">.</span>listen<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
	<span class="br0">&#125;</span>
&nbsp;
	<span class="kw1">private</span> <span class="kw3">function</span> onTilemapResized<span class="br0">&#40;</span>mapW<span class="sy0">:</span>Int<span class="sy0">,</span> mapH<span class="sy0">:</span>Int<span class="br0">&#41;</span><span class="sy0">:</span>Void
	<span class="br0">&#123;</span>
		mapWidth = mapW<span class="sy0">;</span>
		mapHeight = mapH<span class="sy0">;</span>
	<span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>Simples!</p>
<p>Anyways you can check the final result out on this page: <a href="http://mikecann.co.uk/projects/hxaria/02/">http://mikecann.co.uk/projects/hxaria/02/<br />
</a>(Click and drag to move the camera about)</p>
<p>I have also uploaded a quick video too:</p>
<p><iframe width="650" height="471" src="http://www.youtube.com/embed/Hw1bntVoNmU?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>I have also uploaded the source again to my github page: <a href="https://github.com/mikecann/Hxaria">https://github.com/mikecann/Hxaria</a><br />
(I have also created a tag, incase the source changes in the future)</p>
<p>Next up, lighting!</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/personal-project/hxaria-infinite-terrain-haxe-webgldat-gui/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GPU State Preserving Particle Systems with WebGL &amp; HaXe</title>
		<link>http://mikecann.co.uk/personal-project/gpu-state-preserving-particle-systems-with-webgl-haxe/</link>
		<comments>http://mikecann.co.uk/personal-project/gpu-state-preserving-particle-systems-with-webgl-haxe/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 12:02:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GLSL]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Personal Projects]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WebGL]]></category>
		<category><![CDATA[complex]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Particles]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1687</guid>
		<description><![CDATA[Well this is the post I didnt think was going to happen. I have been struggling for weeks with this little bit of tech, ill explain more about why it has been so difficult in another post. For now however, ill just talk about this sample. So the idea was to build upon what I had been [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/10/header01.png"><img class="alignnone size-full wp-image-1688" title="header01" src="http://mikecann.co.uk/wp-content/uploads/2011/10/header01.png" alt="" width="700" height="400" /></a></p>
<p>Well this is the post I didnt think was going to happen. I have been struggling for weeks with this little bit of tech, ill explain more about why it has been so difficult in another post. For now however, ill just talk about this sample.</p>
<p>So the idea was to build upon what I had been working with previously with my <a href="http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/">stateless particles systems with WebGL and HaXe</a>. The intention from the start was to replicate some of my <a href="http://mikecann.co.uk/university-projects/xnagpuparticles-1000000-dynamic-particles/">very early work</a> (from 2007) on state preserving particle systems in WebGL.</p>
<p><strong>Before I go any further, you can check it out in action here:<br />
</strong><strong><a href="http://mikecann.co.uk/projects/HaxeWebGLParticles/">http://mikecann.co.uk/projects/HaxeWebGLParticles/</a> </strong></p>
<p>First a quick reminder. The difference between a stateless and state-preserving particle simulation is that in the latter we store and update the positions, velocities and other properties of each particle per frame, allowing us to interact and control the simulation. This differs from the stateless particle simulation (detailed in my<a href="http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/"> previous post</a>), where the position for each particle is calculated each frame based on a fixed algorithm.</p>
<p>A <a href="http://code.google.com/p/angleproject/issues/detail?id=95">fairly reccent addition</a> to WebGL made this possible, namely texture lookups in the vertex shader (aka Vertex Texture Fetch). I wont go over the exact details how this makes state preserving particle systems possible as I have already documented it in <a href="http://mikecann.co.uk/university-projects/xnagpuparticles-1000000-dynamic-particles/">my earlier work</a>. A brief explanation is that it allows you to use the fragment shader to perform the updates on particle state stored in textures then use the vertex shader to map those states to a point-sprite vertex buffer.</p>
<p>Basically what this means is that the entire particle simulation can be contained and updated on the GPU, which means <a href="http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/">no read-back</a>. This allows us to achieve simulations of <strong>millions</strong> of particles without too much difficulty (depending on GPU ofcourse).</p>
<p><strong>I have uploaded the source for people to perouse at their leisure</strong>:<br />
<a href="https://github.com/mikecann/HaxeWebGLParticles">https://github.com/mikecann/HaxeWebGLParticles</a></p>
<p>As usual it was written using the JS target of HaXe so it should be fairly easy to understand whats going on if you have written any Ecma-script-like-language. Im going to detail this in my next post, but the code isnt the best I have ever written as its a result of a mish-mash of various samples and examples I have found on the web. If anyone has any comments on things that are wrong or could be done better I would be very happy to hear about them.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/personal-project/gpu-state-preserving-particle-systems-with-webgl-haxe/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>5,000,000 Chrome Crawlers? Why not [haXe &amp; WebGL]</title>
		<link>http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/</link>
		<comments>http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 20:38:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[GLSL]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WebGL]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[crawler]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[haxe]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[sprites]]></category>
		<category><![CDATA[stateless]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1602</guid>
		<description><![CDATA[Following on from my previous experiments into the world of haXe and HTML5 I have been playing around again with trying to get as many 2D sprites on screen as I can. I started by reading some posts by google on how to render things fast in HTML5, and it got me thinking. Where I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/08/title.jpg"><img class="alignnone size-full wp-image-1603" title="title" src="http://mikecann.co.uk/wp-content/uploads/2011/08/title.jpg" alt="" width="700" height="400" /></a></p>
<p>Following on from my previous experiments into the world of <a href="http://mikecann.co.uk/personal-project/more-html5-haxe-speed-tests/">haXe and HTML5</a> I have been playing around again with trying to get as many 2D sprites on screen as I can.</p>
<p>I started by reading some posts by google on how to render things fast in HTML5, and it got me thinking. Where I was likely going wrong with my<a href="http://mikecann.co.uk/personal-project/chrome-crawler-haxe-three-js-webgl-and-2d-sprites/"> HaXe + Three.js experiments</a> was that I was making a separate draw call to WebGL for each and every crawler. Draw calls are expensive and hence I was reaching the draw call bottleneck at just 2000 sprites being rendered at once.</p>
<p>What I needed to do was batch the draw calls together and render them at once. I knew from my work on XNA you could group sprite render calls together quite nicely. So I started off coding up a WebGL equivillant of SpriteBatch from XNA.  I managed to get it kind-of working but as is often the way another thought struck my brain, and I decided to tackle that instead.</p>
<p>My thought was; why not just render everything as 2D point sprites? I remembered from my XNA days you <a href="http://mikecann.co.uk/university-projects/xnagpuparticles-1000000-dynamic-particles/">could achieve quite staggering numbers</a> of 2D sprites in DirectX by using point spites.</p>
<p>So after a little bit of fiddling and hacking I managed to get point sprites correctly rendering:</p>
<p><object width="700" height="555" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 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/KhIT9yNEb8g?version=3&amp;hl=en_GB" /><param name="allowfullscreen" value="true" /><embed width="700" height="555" type="application/x-shockwave-flash" src="http://www.youtube.com/v/KhIT9yNEb8g?version=3&amp;hl=en_GB" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<p>You can play with it here: <a href="http://mikecann.co.uk/projects/HTML5SpeedTests/HaXeWebGL/bin/">http://mikecann.co.uk/projects/HTML5SpeedTests/HaXeWebGL/bin/</a></p>
<p>The great thing about point sprites is that I only use one draw call per frame and the GPU is very good at rendering them. The only bottleneck really is the number of pixels you need to draw. With that in mind if you drop the size of the point sprite down to 1&#215;1 you can render a very large (5million) points at interactive framerates (18fps):</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/08/000000000000002.jpg"><img class="alignnone size-full wp-image-1605" title="000000000000002" src="http://mikecann.co.uk/wp-content/uploads/2011/08/000000000000002.jpg" alt="" width="700" height="461" /></a></p>
<p>I added a &#8220;dont use texture&#8221; option just out of interest to see how expensive the texture lookup in the fragment shader was, it didnt seem have much of an effect.</p>
<p>There are a few caveats to using point sprites:</p>
<p>Firstly in <a href="https://github.com/mrdoob/three.js/issues/293">WebGL has a limit</a> on how large you can make them currently it differs between graphics cards and browsers, a safe minimum is 64&#215;64 so this means you cant have them and bigger and still want it to work in all situations.</p>
<p>Secondly, and this one is more important I cheated to get the numbers above. In my other experiments with haXe and WebGL I was using the CPU to update the positions of the crawlers each frame, having them bounce off the screen edges. In this point sprites demo however I have the points flowing out of a fountain, the simulation of which is entirely calculated on the GPU. The reason for this I talked about in a paper I wrote for a university project 4 years ago:</p>
<p><a href="http://mikecann.co.uk/wp-content/uploads/2011/08/Shot_07.png"><img class="alignnone size-full wp-image-1606" title="Shot_07" src="http://mikecann.co.uk/wp-content/uploads/2011/08/Shot_07.png" alt="" width="598" height="819" /></a></p>
<p>If I wasn&#8217;t to perform the upates on the GPU but instead just use the CPU to update the crawlers that would mean the javascript (CPU) would need to update 5million crawlers each frame then re-upload the point sprite positions back to the GPU for rendering. This would obviously be a bad idea.</p>
<p>So I kind of cheated. The fountain simulation on the GPU isn&#8217;t the same as my other examples. The crawlers don&#8217;t bounce off the side of the screen. To make that that happen each crawler needs to somehow preserve its state between frames.</p>
<p>Currently each crawler&#8217;s position is calculated in the vertex shader each frame like so:</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://mikecann.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="glsl" style="font-family:monospace;"><span class="kw2">attribute</span> <span class="kw3">float</span> maxAge<span class="sy0">;</span>
<span class="kw2">attribute</span> <span class="kw3">float</span> startingAge<span class="sy0">;</span>
<span class="kw2">attribute</span> <span class="kw3">float</span> velX<span class="sy0">;</span>
<span class="kw2">attribute</span> <span class="kw3">float</span> velY<span class="sy0">;</span>
&nbsp;
<span class="kw2">uniform</span> <span class="kw3">float</span> uTime<span class="sy0">;</span>
<span class="kw2">uniform</span> <span class="kw3">float</span> uPointSize<span class="sy0">;</span>
&nbsp;
<span class="kw2">varying</span> <span class="kw3">float</span> invAgeRatioSq<span class="sy0">;</span>
&nbsp;
<span class="kw3">void</span> main<span class="br0">&#40;</span><span class="kw3">void</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
	<span class="kw3">float</span> age <span class="sy0">=</span> <span class="kw5">mod</span><span class="br0">&#40;</span>uTime<span class="sy0">+</span>startingAge<span class="sy0">,</span> maxAge<span class="br0">&#41;</span><span class="sy0">;</span>
	<span class="kw3">float</span> ageRatio <span class="sy0">=</span> age <span class="sy0">/</span> maxAge<span class="sy0">;</span>
	<span class="kw3">float</span> invAge <span class="sy0">=</span> 1<span class="sy0">.</span>0 <span class="sy0">-</span> ageRatio<span class="sy0">;</span>
	invAgeRatioSq <span class="sy0">=</span> 1<span class="sy0">.</span>0 <span class="sy0">-</span> <span class="br0">&#40;</span>ageRatio <span class="sy0">*</span> ageRatio<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
	<span class="kw6">gl_Position</span> <span class="sy0">=</span> <span class="kw3">vec4</span><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="sy0">-</span>velX<span class="sy0">*</span>ageRatio<span class="sy0">*</span>0<span class="sy0">.</span>8<span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span>velY<span class="sy0">*</span>ageRatio<span class="br0">&#41;</span><span class="sy0">+</span><span class="br0">&#40;</span><span class="sy0">-</span>0<span class="sy0">.</span>4<span class="sy0">*</span>age<span class="sy0">*</span>ageRatio<span class="br0">&#41;</span><span class="sy0">-</span>0<span class="sy0">.</span>5<span class="sy0">,</span> 0<span class="sy0">.,</span> 1<span class="sy0">.</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
	<span class="kw6">gl_PointSize</span> <span class="sy0">=</span> uPointSize<span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>To preserve state between frames I need to use textures to record each crawlers position and velocity, then using Vertex Texture Fetch a vertices position can be calculated.</p>
<p>That however will have to wait for another evening <img src='http://mikecann.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I have uploaded the source for this project here incase anyone was interested:</p>
<p><a href="http://mikecann.co.uk/projects/HTML5SpeedTests/HTML5SpeedTests_2.zip">http://mikecann.co.uk/projects/HTML5SpeedTests/HTML5SpeedTests_2.zip</a></p>
<p>I warn you its ugly and uncommented, however it should be enough of a start for anyone looking to do something similar.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/programming/5000000-chrome-crawlers-why-not-haxe-webgl/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Particles, Yey!</title>
		<link>http://mikecann.co.uk/fun-videos/particles-yey/</link>
		<comments>http://mikecann.co.uk/fun-videos/particles-yey/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 19:10:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Fun & Videos]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[pretty]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1463</guid>
		<description><![CDATA[Just thought I would share this little thing I was introduced to by a friend. http://grantkot.com/MPM/Liquid.html Its a liquid physics simulator written in Java. Apparently its creator, Grant Kot has been playing around with particles for some time. Theres more of his work on youtube, here is one: Pretty! Edit: Didnt realise but this is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2010/12/Shot_0031.png"><img class="alignnone size-full wp-image-1465" title="Shot_003" src="http://mikecann.co.uk/wp-content/uploads/2010/12/Shot_0031.png" alt="" width="698" height="304" /></a></p>
<p>Just thought I would share this little thing I was introduced to by a friend.</p>
<p><a href="http://grantkot.com/MPM/Liquid.html">http://grantkot.com/MPM/Liquid.html</a></p>
<p>Its a liquid physics simulator written in Java.</p>
<p>Apparently its creator, Grant Kot has been playing around with particles for some time. Theres more of his work on youtube, here is one:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="550" 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/BIQRhOFkvQY?fs=1&amp;hl=en_GB&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="700" height="550" src="http://www.youtube.com/v/BIQRhOFkvQY?fs=1&amp;hl=en_GB&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Pretty!</p>
<p>Edit: Didnt realise but this is the same guy that did Polluted Planet that I covered almost 3 years ago -&gt; <a href="http://mikecann.co.uk/fun-videos/polluted-planet/">http://mikecann.co.uk/fun-videos/polluted-planet/</a> thats some awesome particle based dedication right there, I think I need to buy him a beer <img src='http://mikecann.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/fun-videos/particles-yey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joa Does It Again!</title>
		<link>http://mikecann.co.uk/programming/joa-does-it-again/</link>
		<comments>http://mikecann.co.uk/programming/joa-does-it-again/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 23:28:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[joa]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1298</guid>
		<description><![CDATA[So I have written about Mr Joa &#8216;The Flash God&#8217; Ebert before. He is well known throughout the Flash community for his incredible coding skills, particularly his work on low-level SWF optimisation. His latest project is called JITB and its nothing short of stunning as this video taken from his blog shows: Basically he has gone [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-31-14.04.jpg"><img class="alignnone size-full wp-image-1300" title="ScreenHunter_01 Aug. 31 14.04" src="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-31-14.04.jpg" alt="" width="678" height="380" /></a></p>
<p>So I have <a href="http://mikecann.co.uk/flash/funk-ioc-a-new-dependency-injection-framework/">written about Mr Joa &#8216;The Flash God&#8217; Ebert before</a>. He is well known throughout the Flash community for his incredible coding skills, particularly his work on low-level SWF optimisation.</p>
<p>His latest project is called JITB and its nothing short of stunning as this video taken <a href="http://blog.joa-ebert.com/2010/08/31/so-i-recorded-a-new-video/">from his blog</a> shows:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="550" 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/atzHF7YGp6Y?fs=1&amp;hl=en_GB&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="700" height="550" src="http://www.youtube.com/v/atzHF7YGp6Y?fs=1&amp;hl=en_GB&amp;hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Basically he has gone and written a Flash Player in Java. What this means is that you get all those awesome speed benefits and optimisations that the Java team has worked hard for years and years to implement but you can write it all in a language already familiar and sexy, AS3! The result? You get about a 30x speedup! (disclaimer: a micro-benchmark taken from Joa&#8217;s blog)</p>
<p>This is all great news and very exciting. I cant wait to see a custom browser plugin using this flash player, or even having Pixel Bender shaders running on the hardware *me drools in anticipation*.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/programming/joa-does-it-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ludum Dare &#8211; Hour 31</title>
		<link>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-31/</link>
		<comments>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-31/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 08:37:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ludum Dare]]></category>
		<category><![CDATA[48hours]]></category>
		<category><![CDATA[bloom]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[gameplay]]></category>
		<category><![CDATA[Liero]]></category>
		<category><![CDATA[ludum]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[worms]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1261</guid>
		<description><![CDATA[Well its been quite a while since my last progress report. I have mostly been sleeping (well 4 hours of it anyways). So progress is coming along nicely STILL no gameplay tho :S So far you can shoot and destroy the enemies and then collect thier giblets before they become part of the terrain. The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-22-09.36.jpg"><img class="alignnone size-full wp-image-1262" title="ScreenHunter_01 Aug. 22 09.36" src="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-22-09.36.jpg" alt="" width="664" height="599" /></a></p>
<p>Well its been quite a while since my last progress report. I have mostly been sleeping (well 4 hours of it anyways).</p>
<p>So progress is coming along nicely STILL no gameplay tho :S</p>
<p>So far you can shoot and destroy the enemies and then collect thier giblets before they become part of the terrain. The idea is that you can then shoot those giblets back at the enemies. Take alook if you are interested:</p>
<p><object style="width: 600px; height: 500px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="500" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.mikecann.co.uk/DumpingGround/ld/18/04/LudumDare18.swf" /><embed style="width: 600px; height: 500px;" type="application/x-shockwave-flash" width="600" height="500" src="http://www.mikecann.co.uk/DumpingGround/ld/18/04/LudumDare18.swf"></embed></object></p>
<p>Oh I just noticed I left some debug sliders on there I was using to try and hone the bloom levels. Have a play with them if you want.</p>
<p>Right. Gameplay.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-31/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ludum Dare &#8211; Hour 17</title>
		<link>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-17/</link>
		<comments>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-17/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 18:34:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ludum Dare]]></category>
		<category><![CDATA[bloom]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Liero]]></category>
		<category><![CDATA[ludum]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Project]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1251</guid>
		<description><![CDATA[Okay its been about 6 hours since my last update, and I have been working pretty much solid apart from an hour lunchbreak when I went for a wander into town. Ive made quite abit of progress with the core bits of the engine including the physics particle systems and the destructible terrain. Dont believe [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-21-19.31.jpg"><img class="alignnone size-full wp-image-1252" title="ScreenHunter_01 Aug. 21 19.31" src="http://mikecann.co.uk/wp-content/uploads/2010/08/ScreenHunter_01-Aug.-21-19.31.jpg" alt="" width="682" height="595" /></a></p>
<p>Okay its been about 6 hours since my last update, and I have been working pretty much solid apart from an hour lunchbreak when I went for a wander into town.</p>
<p>Ive made quite abit of progress with the core bits of the engine including the physics particle systems and the destructible terrain.</p>
<p>Dont believe me? Take a look for yourself:</p>
<p><object style="width: 600px; height: 500px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="500" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.mikecann.co.uk/DumpingGround/ld/18/02/LudumDare18.swf" /><embed style="width: 600px; height: 500px;" type="application/x-shockwave-flash" width="600" height="500" src="http://www.mikecann.co.uk/DumpingGround/ld/18/02/LudumDare18.swf"></embed></object></p>
<p>Theres still no game really, just a pretty tech demo. Im hoping the gameplay will come next <img src='http://mikecann.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Im going to have abit of a break now, get some food wind down a little then its going to be a loooooong night ahead for me!</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/ludum-dare/ludum-dare-hour-17/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Assembly 2010 &#8211; CNCD &amp; Fairlight Demo</title>
		<link>http://mikecann.co.uk/fun-videos/assembly-2010-cncd-fairlight-demo/</link>
		<comments>http://mikecann.co.uk/fun-videos/assembly-2010-cncd-fairlight-demo/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 17:08:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Fun & Videos]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[cncd]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[fairlight]]></category>
		<category><![CDATA[glitch]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[lan]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[party]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1198</guid>
		<description><![CDATA[It was the massive annual Assembly gathering last week. Traditionally its a place for the demo scene to gather and present their demos and to hack out new ones. For those not in the know the demo scene or &#8220;scene&#8221; is where a team of people come together and compete to make a music video. Except that they [...]]]></description>
			<content:encoded><![CDATA[<p>It was the massive annual Assembly gathering last week. Traditionally its a place for the <a href="http://scene.org">demo scene</a> to gather and present their demos and to hack out new ones.</p>
<p>For those not in the know the demo scene or &#8220;scene&#8221; is where a team of people come together and compete to make a music video. Except that they arent videos in the traditional sense as its all generated using code and runs in realtime. This means that you have to be super efficient with your code. Some of the competitions are &#8220;64k&#8221; or even &#8220;4k&#8221; competitions which means that the whole demo must fit in 64kb or 4kb! The music is also produced by the groups and often excellent.</p>
<p>I have been checking out some of the demos produced by the teams this year and they are simply stunning. Every year they get better and better.</p>
<p>This one from CNCD and Fairlight particularly caught my eye as it has massive numbers of particles and a stunning soundtrack kinda reminiscent of glitchy Radiohead. Therefore I thought it essential I share it here.</p>
<p>Enjoy:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="418" 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/vQ2iQQvofCE&amp;hl=en_GB&amp;fs=1?hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="700" height="418" src="http://www.youtube.com/v/vQ2iQQvofCE&amp;hl=en_GB&amp;fs=1?hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Oh while im at it check out this one from last year:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="418" 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/ezltebzdgjI&amp;hl=en_GB&amp;fs=1?hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="700" height="418" src="http://www.youtube.com/v/ezltebzdgjI&amp;hl=en_GB&amp;fs=1?hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>If you are interested in more demos from assembly you can get them all here: <a href="http://scene.org/newfiles.php?dayint=7&amp;dir=/parties/2010/assembly10/">http://scene.org/newfiles.php?dayint=7&amp;dir=/parties/2010/assembly10/</a></p>
<p>Oh I have also posted about the demoscene before here: <a href="http://mikecann.co.uk/art/andromeda-software-development-lifeforce-2007/">http://mikecann.co.uk/art/andromeda-software-development-lifeforce-2007/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/fun-videos/assembly-2010-cncd-fairlight-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incredible Particle &amp; Physics Video</title>
		<link>http://mikecann.co.uk/fun-videos/incredible-particle-physics-video/</link>
		<comments>http://mikecann.co.uk/fun-videos/incredible-particle-physics-video/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 17:37:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Fun & Videos]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[Impressive]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Physics]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://mikecann.co.uk/?p=1142</guid>
		<description><![CDATA[Saw this post on Gizmodo and thought I would share on my blog as I think its incredible. Its a a physics engine called Lagoa and its by Thiago Costa, check it out: Lagoa Multiphysics 1.0 &#8211; Teaser from Thiago Costa on Vimeo.]]></description>
			<content:encoded><![CDATA[<p>Saw this <a href="http://gizmodo.com/5591613/incredible-physics-engine-yields-some-seriously-jaw+dropping-dirt">post on Gizmodo</a> and thought I would share on my blog as I think its incredible.</p>
<p>Its a a physics engine called Lagoa and its by Thiago Costa, check it out:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" 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://vimeo.com/moogaloop.swf?clip_id=13457383&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://vimeo.com/moogaloop.swf?clip_id=13457383&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/13457383">Lagoa Multiphysics 1.0 &#8211; Teaser</a> from <a href="http://vimeo.com/thiagocosta">Thiago Costa</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/fun-videos/incredible-particle-physics-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quasimondo&#039;s Galactose</title>
		<link>http://mikecann.co.uk/programming/actionscript/quasimondos-galactose/</link>
		<comments>http://mikecann.co.uk/programming/actionscript/quasimondos-galactose/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 20:17:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Particles]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.mikecann.co.uk/?p=830</guid>
		<description><![CDATA[I have immense respect for some of the flash developers out there and Quasimondo is one of them. He has just released a little particle related experiment. Whenever I see these kind of things it inspires me to bash out my own little experiments. I wont talk too much about it but check it out [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikecann.co.uk/wp-content/uploads/2010/01/ScreenHunter_02-Jan.-10-20.13.jpg"><img class="alignnone size-full wp-image-831" title="ScreenHunter_02 Jan. 10 20.13" src="http://mikecann.co.uk/wp-content/uploads/2010/01/ScreenHunter_02-Jan.-10-20.13.jpg" alt="ScreenHunter_02 Jan. 10 20.13" width="688" height="365" /></a></p>
<p>I have immense respect for some of the flash developers out there and Quasimondo is one of them. He has just released a little particle related experiment.</p>
<p>Whenever I see these kind of things it inspires me to bash out my own little experiments.</p>
<p>I wont talk too much about it but check it out on this lab page: <a href="http://incubator.quasimondo.com/flash/galactose.php">http://incubator.quasimondo.com/flash/galactose.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikecann.co.uk/programming/actionscript/quasimondos-galactose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

