<?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>Smart-Page.net &#187; C Sharp</title>
	<atom:link href="http://www.smart-page.net/blog/category/c-sharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.smart-page.net/blog</link>
	<description>C++ / C# / Actionscript / Py ... &#039;My God. It&#039;s full of stars!&#039;</description>
	<lastBuildDate>Tue, 27 Jul 2010 21:35:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Conway&#8217;s Game of Life 3D &#8211; huge amount of objects in Unity</title>
		<link>http://www.smart-page.net/blog/2010/06/10/conway%c2%b4s-game-of-life-3d-huge-amount-of-objects-in-unity/</link>
		<comments>http://www.smart-page.net/blog/2010/06/10/conway%c2%b4s-game-of-life-3d-huge-amount-of-objects-in-unity/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 13:24:49 +0000</pubDate>
		<dc:creator>flashgordon</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Unity 3D]]></category>
		<category><![CDATA[CombineMeshes]]></category>
		<category><![CDATA[Conway]]></category>
		<category><![CDATA[Game of Life]]></category>

		<guid isPermaLink="false">http://www.smart-page.net/blog/?p=1032</guid>
		<description><![CDATA[<a href="http://www.smart-page.net/blog/2010/06/10/conway%c2%b4s-game-of-life-3d-huge-amount-of-objects-in-unity/" title="Conway&#8217;s Game of Life 3D &#8211; huge amount of objects in Unity"><img src="http://www.smart-page.net/blog/wp-content/uploads/yapb_cache/gol.3k7231q2u7eokgock0csgw0k0.h9fw4mcunnwo4cowc8k4840k.th.jpeg" width="200" height="150" alt="Conway&#8217;s Game of Life 3D &#8211; huge amount of objects in Unity" style="float:left;padding:0 10px 10px 0;" ></a>Surely you have already heard of Conway&#8217;s cellular automaton &#8211; the Game of Life.
For those who haven&#8217;t, it&#8217;s a simulation of cells interacting with their neighbors by following a simple rule set on an infinite, two dimensional grid.
So let&#8217;s add a dimension -> view the game of life in 3D!

The Game of Life has become [...]]]></description>
			<content:encoded><![CDATA[<a href="http://www.smart-page.net/blog/2010/06/10/conway%c2%b4s-game-of-life-3d-huge-amount-of-objects-in-unity/" title="Conway&#8217;s Game of Life 3D &#8211; huge amount of objects in Unity"><img src="http://www.smart-page.net/blog/wp-content/uploads/yapb_cache/gol.3k7231q2u7eokgock0csgw0k0.h9fw4mcunnwo4cowc8k4840k.th.jpeg" width="200" height="150" alt="Conway&#8217;s Game of Life 3D &#8211; huge amount of objects in Unity" style="float:left;padding:0 10px 10px 0;" ></a><p>Surely you have already heard of <a href="http://en.wikipedia.org/wiki/John_Horton_Conway" target="_blank">Conway</a>&#8217;s <a href="http://en.wikipedia.org/wiki/Cellular_automaton" target="_blank">cellular automaton</a> &#8211; the <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank">Game of Life</a>.</p>
<p>For those who haven&#8217;t, it&#8217;s a simulation of cells interacting with their neighbors by following a <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Rules" target="_blank">simple rule set</a> on an infinite, two dimensional grid.</p>
<p><strong>So let&#8217;s add a dimension -> <a href="http://www.smart-page.net/unity/sp_gol/" target="_blank">view the game of life in 3D</a>!</strong></p>
<p><span id="more-1032"></span><br />
The Game of Life has become famous not only in theoretical computer science, for it is <a href="http://en.wikipedia.org/wiki/Turing_complete" target="_blank">Turing Complete</a>, generates the most interesting <a href="http://conwaylife.com/wiki/index.php?title=Category:Patterns" target="_blank">patterns</a> and is easy to implement.<br />
In flash it can be <a href="http://www.smart-page.net/as3/sp_life" target="_blank">done</a> in &#8216;one line&#8217; of code by means of a convolution filter.</p>
<p>So since 1970 the Game of Life has been explored by almost every programmer, it&#8217;s no surprise its &#8220;Glider&#8221; pattern became the official &#8220;<a href="http://en.wikipedia.org/wiki/Hacker_emblem" target="_blank">Hacker Emblem</a>&#8221; in 2003.</p>
<p>Customarily it&#8217;s visualized by a 2D representation of the board/grid &#8211; however, it can be applied to 1D and 3D space as well.</p>
<p>While I find 3D versions/rule sets to be interesting too, there is a much simpler way to lift the game into three dimensions that also generates more beautiful patterns:<br />
Simply plotting the (visible) game grid´s state over time on the third axis perfectly visualizes the process and generates amazing shapes&#8230; or at least very interesting greebles <img src='http://www.smart-page.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<br/><br />
<h2>Why Unity?</h2>
<p>The only issue is the amount of cells to draw &#8211; visualizing a small 10*10 field over 100 generations already means handling up to 10k cubes or sprites.</p>
<p>And I had an even higher amount in mind, so flash wouldn&#8217;t get me anywhere this time.</p>
<p><img src="http://www.smart-page.net/blog/wp-content/uploads/2010/06/gol3.jpg" alt="" title="gol3" width="683" height="169" class="alignnone size-full wp-image-1084" /></p>
<p>First I thought about building a standalone app, then using <a href="http://processing.org/" target="_blank">Processing</a> or <a href="http://www.py4d.com/" target="_blank">Py4D</a>&#8230;</p>
<p>There it hit me &#8211; Unity! As long as OpenGL isn&#8217;t native to the web, <a href="http://unity3d.com/" target="_blank">Unity 3D</a> is definitely the best way to deliver intensive 3D games/apps via the browser.</p>
<p>As Unity offers C# as scripting language I immediately feel at home. Unity 3D reviewed in one word: Awesome!<br />
<br/><br />
<h2>The draw call issue</h2>
<p>But there is always a stumbling block hidden somewhere.</p>
<p>Since I am generating a lot of cubes (cells) on every frame, unity has to do a huge amount of draw calls &#8211; one for each object.<br />
The frame rate on my machine (Q6600, GF8600) dropped right into the basement.</p>
<p>The simple solution to this issue was to generate the complete generation of cubes and to fuse them to one single mesh using <a href="http://unity3d.com/support/documentation/ScriptReference/Mesh.CombineMeshes.html" target="_blank"><em>Mesh.CombineMeshes</em></a>.<br />
Normally this is done on startup  &#8211;  for the exact purpose of reducing draw calls &#8211; and I thought it could also be used at runtime for this scenario.</p>
<p>As objects are limited to 65k vertices, it wasn&#8217;t possible to merge the complete scene into one mesh, but that might have quickly become too time intensive as well.</p>
<p>So finally I was able to animate/display more than a million vertices.</p>
<p><img src="http://www.smart-page.net/blog/wp-content/uploads/2010/06/gol12.jpg" alt="" title="gol1" width="683" height="169" class="alignnone size-full wp-image-1081" /><br />
<br/><br />
<h2>Conclusion</h2>
<p>The app now draws a 50*50 grid over a time of 200 generations &#8211; press space to reset the game and seed a new field of life cells.</p>
<p>Admittedly, it takes a lot of resources &#8211; a graphic adapter with at least 128MB is essential as the simulation might end up with 1.5 million vertices.</p>
<p><br/><br />
Hope you get to see some interesting patterns &#8211; have fun!<br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.smart-page.net/blog/2010/06/10/conway%c2%b4s-game-of-life-3d-huge-amount-of-objects-in-unity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Smart Normal Map goes Silverlight</title>
		<link>http://www.smart-page.net/blog/2009/08/27/smart-normal-map-goes-silverlight/</link>
		<comments>http://www.smart-page.net/blog/2009/08/27/smart-normal-map-goes-silverlight/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:00:05 +0000</pubDate>
		<dc:creator>flashgordon</dc:creator>
				<category><![CDATA[C Sharp]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[normapmap]]></category>
		<category><![CDATA[PixelBender]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.smart-page.net/blog/?p=370</guid>
		<description><![CDATA[<a href="http://www.smart-page.net/blog/2009/08/27/smart-normal-map-goes-silverlight/" title="Smart Normal Map goes Silverlight"><img src="http://www.smart-page.net/blog/wp-content/uploads/yapb_cache/smartnormalsilver2_copy.dxgzs37jwt4c4swsoc88wo8s8.h9fw4mcunnwo4cowc8k4840k.th.jpeg" width="200" height="150" alt="Smart Normal Map goes Silverlight" style="float:left;padding:0 10px 10px 0;" ></a>Microsofts Silverlight has advanced to a level where it´s features and performance get contrastable  with flash.
It took mere minutes to port Smart Normal from PixelBender (Hydra) to Silverlights shader Language HLSL (DirectX).
As with Astro, shaders are rendered via software &#8211; not the GPU.
The result is roughly comparable with this Flash demo of Smart Normal.
This [...]]]></description>
			<content:encoded><![CDATA[<a href="http://www.smart-page.net/blog/2009/08/27/smart-normal-map-goes-silverlight/" title="Smart Normal Map goes Silverlight"><img src="http://www.smart-page.net/blog/wp-content/uploads/yapb_cache/smartnormalsilver2_copy.dxgzs37jwt4c4swsoc88wo8s8.h9fw4mcunnwo4cowc8k4840k.th.jpeg" width="200" height="150" alt="Smart Normal Map goes Silverlight" style="float:left;padding:0 10px 10px 0;" ></a><p>Microsofts Silverlight has advanced to a level where it´s features and performance get contrastable  with flash.</p>
<p>It took mere minutes to port Smart Normal from PixelBender (Hydra) to Silverlights shader Language HLSL (DirectX).<br />
As with Astro, shaders are rendered via software &#8211; not the GPU.</p>
<p><b><a href="http://www.smart-page.de/sl/sp_smartnormal_silver/" target="_blank">The result</a></b> is roughly comparable with <a href="http://www.smart-page.net/as3/sp_smartnormalmap" target="_blank">this Flash demo</a> of <a href="http://www.smart-page.net/smartnormal" target="_blank">Smart Normal</a>.</p>
<p>This was not intended to be a performance test but it clearly indicates that Silverlight isn´t inferior when it comes to video, shading or 2,5D.</p>
<p><span id="more-370"></span></p>
<p>C# is a mighty language -  easy to pickup for those who are familiar with C++ and working with XAML even feels natural to a Flex developer.</p>
<p>It has to be seen where Open Source, Google, Adobe and Microsoft will take the &#8216;web 3.0&#8242; but Silverlight definetly has the potential to be a part of that future.<br />
In general, competition is a good thing when it comes to software and the same applies to RIA runtimes&#8230;</p>
<p>View the <a href="http://www.smart-page.de/sl/sp_smartnormal_silver/" target="_blank">Silverlight Smart Normal demo</a> or download the Smart Notmal shader as <a href="http://www.smart-page.de/sl/sp_smartnormal_silver/SmartNormal.fx" target="_blank">HLSL *.fx file</a>.</p>
<p><em>Hint</em>: If you are looking for a PixelBender Toolkit replacement when working with HLSL try <a href="http://shazzam-tool.com/" target="_blank">Shazzam</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smart-page.net/blog/2009/08/27/smart-normal-map-goes-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
