<?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>Friendly patterns and algorithms &#187; graphics</title>
	<atom:link href="http://www.palgorithm.co.uk/tag/graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.palgorithm.co.uk</link>
	<description>Discussion of algorithms for games, graphics and general engineering</description>
	<lastBuildDate>Mon, 31 May 2010 11:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The beauty of software development</title>
		<link>http://www.palgorithm.co.uk/2009/05/the-beauty-of-software-development/</link>
		<comments>http://www.palgorithm.co.uk/2009/05/the-beauty-of-software-development/#comments</comments>
		<pubDate>Wed, 27 May 2009 19:05:33 +0000</pubDate>
		<dc:creator>Sam Martin</dc:creator>
				<category><![CDATA[thoughts]]></category>
		<category><![CDATA[beauty]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://www.palgorithm.co.uk/2009/05/the-beauty-of-software-development/</guid>
		<description><![CDATA[This is all about how amazing software development really is.
Taking &#8220;X&#8221; to be a geeky subject: The belief that &#8220;X&#8221; is truly a thing of beauty but scorned, unloved and misunderstood by the masses is by no means a modern concept. But it lingers on all the same. I suppose it&#8217;s no coincidence that the [...]]]></description>
			<content:encoded><![CDATA[<p>This is all about how amazing <b>software development </b>really is.</p>
<p>Taking &#8220;X&#8221; to be a geeky subject: The belief that &#8220;X&#8221; is truly a thing of beauty but scorned, unloved and misunderstood by the masses is by no means a modern concept. But it lingers on all the same. I suppose it&#8217;s no coincidence that the culmination of many geeky subjects into a sort of geeky mega-subject (software development) might attract a bit more than it&#8217;s fair share of abuse. People at least have some <i>respect </i>for mathematicians and physicists, even if they choose to distance themselves. Tell people you develop software for a living and they promptly fall asleep, or complain that their computer never works. Unless of course, you develop <i>games </i>for a living at which point you become every kid&#8217;s best friend. (It&#8217;s a strategy I highly recommend.)</p>
<p>Here&#8217;s a few thoughts and some of my favourite quotes on the topic of beauty and software. </p>
<p><b>Art</b><br />First up is <a target="_blank" href="http://en.wikipedia.org/wiki/Donald_Knuth">Donald Knuth&#8217;s</a>, <a target="_blank" href="http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming">&#8220;Art of computer programming&#8221;</a>. For non-coders out there, this book is the equivalent of Steven Hawkings, &#8220;Brief History of Time&#8221;, to most people: Everyone has heard of it. Many people own a copy. Some people have even attempted to read it but few have actually completed it and even less understood it. It&#8217;s the kind of &#8220;compulsory reading&#8221; that most programmers skip but know they probably shouldn&#8217;t have.</p>
<p>Knuth justifies his use of the word &#8220;Art&#8221; in the title:<br />
<blockquote>Computer programming is an art, because it applies accumulated knowledge to the world, because it requires skill and ingenuity, and especially because it produces objects of beauty. A programmer who subconsciously views himself as an artist will enjoy what he does and will do it better.</p></blockquote>
<p>You can almost hear a revolt starting.</p>
<p>Is coding Art? Well, I think there&#8217;s one thing missing in Knuth&#8217;s description that would make his assertion particularly convincing &#8211; Art can tell you something about humanity. Can your code do that? Well, I&#8217;m not sure. But, in the defense of code and the study of patterns in general, there are features and patterns of the world that are better reflected through them than Art. I think some of these patterns are surprisingly deep and beautiful &#8211; eigenvectors are the first to spring to mind. Certainly beautiful enough that I&#8217;d hang them on my wall if I could capture them in a picture.</p>
<p><b>Expression</b><br />You can express yourself through Art. Can you express yourself through code? Certainly. The most obvious example of this is the rapidly growing cross-over world of programming visual artists. Generative art is a topic all of it&#8217;s own, so I&#8217;ll just recommend anyone interested to check out <a target="_blank" href="http://processing.org/">Processing</a> and follow links from there. I&#8217;m a fan of <a target="_blank" href="http://www.flight404.com">Robert Hodgin</a>, especially <a target="_blank" href="http://vimeo.com/935317?pg=embed&amp;sec=">this</a>.</p>
<p>Is it possible to be defined by your creations, as many artists become defined by their output? This seems to be true of <a target="_blank" href="http://www.1014.org/">Justin Frankel</a>, creator of several popular and <a target="_blank" href="http://en.wikipedia.org/wiki/Justin_Frankel">sometimes controversial</a> projects. There&#8217;s a popular quote to go with his resignation from AOL to go with this, but please be aware I&#8217;m including it with some reservations as it&#8217;s second hand and comes from a somewhat <a target="_blank" href="http://www.slate.com/id/2109615/">opinionated article</a>. Just be aware it might be porky pies:<br />
<blockquote>For me, coding is a form of self-expression. The company controls the most effective means of self-expression I have. This is unacceptable to me as an individual, therefore I must leave.</p></blockquote>
<p>(I should probably also note his most recent project, <a target="_blank" href="http://www.reaper.fm/">REAPER</a>, is absolutely fantastic and all you Cubase users should jump ship immediately.)</p>
<p><b>Elegance</b><br />I might be nitpicking, but I suspect the most common understanding of &#8216;beauty&#8217; in reference to code is actually something closer to &#8216;elegance&#8217; rather than beauty as such. Code elegance is arguably the reading-between-the-lines topic of many software engineering mailing lists. </p>
<p>Some noteworth texts from the small to the large include a decent blog post, <a target="_blank" href="http://avdi.org/devblog/2008/04/27/on-beauty-in-code/">On Beauty in Code</a>; a presentation on how to go about <a target="_blank" href="http://laurat.blogs.com/talks/write_beautiful_code.pdf">writing beautiful code</a> (in PHP of all things!); and of course there&#8217;s a rather interesting looking book, <a target="_blank" href="http://books.google.co.uk/books?id=gJrmszNHQV4C&amp;dq=Beautiful+Code&amp;printsec=frontcover&amp;source=bn&amp;hl=en&amp;ei=H0EdStb4I4eRjAfxvbmSDQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=4#PPP1,M1">Beautiful Code</a>. I haven&#8217;t read this yet, but intend to shortly. The highlight for me is an interesting review of a review of the book entitled, <a target="_blank" href="http://www.codinghorror.com/blog/archives/001062.html">Code isn&#8217;t beautiful</a>:<br />
<blockquote>Ideas are beautiful. Algorithms are beautiful. Well executed ideas and algorithms are even more beautiful. But the code itself is not beautiful. <b>The beauty of code lies in the architecture, the ideas, the grander algorithms and strategies that code <i>represents</i>.</b></p></blockquote>
<p>I think that&#8217;s pretty much on the button.</p>
<p><b>Architecture</b><br />If your code was a building &#8211; an analogy that happens to be a good fit a lot of the time &#8211; you could marvel at it&#8217;s architecture. You could be impressed by the construction, or the balance of functionality and aesthetics. And like appreciation of architecture, a lot can be in the eye of the beholder! </p>
<p><b>Coventry&#8217;s Belgade Theatre.</b><br /><img alt="" title="" style="max-width: 800px;" src="http://www.e-architect.co.uk/birmingham/jpgs/belgrade_theatre_stantonwilliams250408_1.jpg" height="" width="495" /><br />Is it a <a target="_blank" href="http://www.e-architect.co.uk/birmingham/belgrade_theatre_coventry.htm">&#8220;bold and dynamic&#8221;</a> statement, developed through a <a target="_blank" href="http://www.e-architect.co.uk/birmingham/belgrade_theatre_coventry.htm">&#8220;sculpural process&#8221;</a> where <a target="_blank" href="http://www.e-architect.co.uk/birmingham/belgrade_theatre_coventry.htm">&#8220;the spaces that it embraces, and that it implies around itself, are as important as the form itself&#8221;</a>? Or, an unimaginative concrete cube ungracefully slapped into the middle of an already concrete-heavy town, representing little but the staggering lack of inspiration present in its creators? You decide! Comparisons with your most loved or love-to-hate software engineering projects as comments please.</p>
<p><b>Creation</b><br />Ignoring the code and algorithms for a moment, it&#8217;s undeniable that the output of code can be beautiful &#8211; after all it&#8217;s a major goal of computer graphics research. And not all of it involves artists in the traditional sense. Data visualisation has become a big topic in recent years. I find the growth of this area quite fascinating as it produces attractive, often intriguing images but apparently skipping over the role of an artist in a traditional sense and deriving input purely from real world data. It&#8217;s arguably an expression of humanity &#8211; although not quite in the same sense I originally had in mind!</p>
<p>On a personal note, I still remember the first implementation of our radiosity algorithm emerge. The whole thing happened quite quickly and we lost several days to just playing with it: tweaking the scene, changing the lights, adding some post processing. It was something none of us had seen before, and it took us quite by surprise. I&#8217;d had that feel-good effect from previous projects, but there&#8217;s something about actually being able to see the result and play with it that makes it all the more tangible.</p>
<p><b>Process<br /></b>I clearly remember my tutor at university complaining that too many people focus on <i>process </i>over <i>product</i>. In fact, he was my <i>music </i>tutor complaining about composers, but the point applies very well to software engineering. But that&#8217;s not to say there isn&#8217;t beauty &#8211; even joy &#8211; to gain from the creation of code. This leads me to my last, but perhaps favourite quote of all time. Here&#8217;s Alexander Stepanov (author of the C++ standard library) and Mat Marcus in some <a target="_blank" href="http://www.stepanovpapers.com/">lecture notes</a>: <br />
<blockquote>Programming has become a disreputable, lowly activity. More and more programmers try to become managers, product managers, architects, evangelists – anything but writing code. It is possible now to find a professor of Computer Science who never wrote a program. And it is almost impossible to find a professor who actually writes code that is used by anyone: the task of writing code is delegated to graduate students. Programming is wonderful. The best job in the world is to be a computer programmer. Code can be as beautiful as the periodic table or Bach’s Well Tempered Clavier.</p></blockquote>
<p>It&#8217;s one of my favourite quotes because it&#8217;s so passionate: I too love programming! I love patterns and algorithms! The world is fantastic!</p>
<p>But &#8211; and it&#8217;s a big but &#8211; that quote simulateously shines light on the big elephant in the room: Software development is programming <b>but with people</b>. That &#8216;people&#8217; part is vitally important, and is occasionally neglected by programmers of code, beautiful or otherwise. It mustn&#8217;t be. Coding is empowering, but the power still lies with people. I suspect software development does have a thing or two to tell us about humanity.</p>
<p>And that&#8217;s why software development really is amazing. Even if it&#8217;s simultaneous one of the most mind-numbingly difficult, painful and exhilarating things I can think of.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.palgorithm.co.uk/2009/05/the-beauty-of-software-development/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Maths and ShaderX8</title>
		<link>http://www.palgorithm.co.uk/2009/04/maths-and-shaderx8/</link>
		<comments>http://www.palgorithm.co.uk/2009/04/maths-and-shaderx8/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 12:15:18 +0000</pubDate>
		<dc:creator>Sam Martin</dc:creator>
				<category><![CDATA[thoughts]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[shaderx]]></category>

		<guid isPermaLink="false">http://www.palgorithm.co.uk/?p=172</guid>
		<description><![CDATA[ShaderX7 is out
ShaderX7 has now hit the press in the USA, although (at the time of writing) it looks like the UK will have to wait a bit longer. I was luck enough to nab a copy directly from the publisher while at GDC. The first thing you notice is it&#8217;s really fat this time [...]]]></description>
			<content:encoded><![CDATA[<p><strong>ShaderX7 is out</strong></p>
<p><img style="float: left; margin-top: 10px; margin-bottom: 10px; margin-right: 10px;" class="size-full wp-image-159 alignnone" title="ShaderX7 Cover Art" src="http://www.palgorithm.co.uk/wp-content/uploads/2009/04/shaderx7_cvrart_small.jpg" alt="ShaderX7 Cover Art" width="100" height="122" /><a href="http://www.shaderx7.com/index.html">ShaderX7</a> has now hit the press in the <a href="http://www.amazon.com/ShaderX7-Rendering-Techniques-Wolfgang-Engel/dp/1584505982">USA</a>, although (at the time of writing) it looks like the <a href="http://www.amazon.co.uk/ShaderX7-Rendering-Techniques-Wolfgang-Engel/dp/1584505982">UK</a> will have to wait a bit longer. I was luck enough to nab a copy directly from the publisher while at <a href="http://www.gdconf.com/">GDC</a>. The first thing you notice is it&#8217;s <em>really</em> fat this time &#8211; definitely one of the largest books on my shelf. It&#8217;s not short on material and Amazon are currently selling it for<span class="priceLarge"> a bargain      $37.79</span><span class="priceLarge"> &#8211; rather short of the </span>$59.99 RRP. Go grab yourself a copy.</p>
<p>Editing the shadows section was my first adventure into the world of publishing, and I&#8217;m glad I put in the effort. I was genuinely&nbsp; surprised by the amount of time involved in editing just 4 articles, so my hat goes off to everyone &#8211; authors and editors alike &#8211; that contribute to these industry-led books. It&#8217;s not done for money, it&#8217;s very definitely a labour of love, and I&#8217;m happy that the end result made the work worthwhile.</p>
<p><strong>ShaderX8 &#8211; now with added maths</strong></p>
<p>Which leads me onto <a href="http://www.shaderx8.com/index.html">ShaderX8</a>! This time around there will be a new section on <strong>Mathematics</strong>, which Wolfgang is kindly allowing me to get my editing paws on. The idea here is that the complexity and quantity of maths involved in writing <a href="http://en.wikipedia.org/wiki/Shader">shaders</a> has greatly increased in recent times. Early shader models had pretty limited capabilities and most uses of them likely capped out at requiring knowledge of linear algebra &#8211; say, vectors, homogeneous matrices, and so on.&nbsp; But we are now fast approaching being able to run <a href="http://en.wikipedia.org/wiki/Larrabee_%28GPU%29">typical x86 code on a GPU</a> and the mathematical models being run are getting correspondingly more complex. There&#8217;s also more than one way of boiling your mathematical eggs, and performance matters. Part of the process in writing shaders is learning, developing and optimising mathematical models &#8211; hence the dedicated new section.</p>
<p>The book is still at proposal stage so what this section really needs now are some <strong>article proposals</strong>. Please take a look at the schedule on the<a href="http://www.shaderx8.com/"> ShaderX</a> website and <a href="email://wolf@shaderx.com">email your proposals to Wolfgang</a> before <strong>17th May 09</strong>. If you have any questions on the maths section feel free to <a href="email://sam@palgorithm.co.uk">email me</a> as well. The writing guidelines can be found <a href="http://www.shaderx6.com/ShaderX6.zip">here</a>.</p>
<p><strong>Complexity of maths in shaders</strong></p>
<p>Here&#8217;s my 2p on the complexity of maths in modern shaders. </p>
<p>I expect almost all graphics programmers will now at least have heard of <a href="http://en.wikipedia.org/wiki/Spherical_harmonics">spherical harmonics</a> as they are an extremely efficient way of capturing lighting irradiance. Given their importance, there have been several <a href="http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf">excellent</a> <a href="http://home.comcast.net/%7Etom_forsyth/papers/SH_GDCE_TomF.zip">tutorials</a> written to help the games industry understand how they work. But my impression of the industry is that many people&#8217;s understanding of them is not yet at &#8220;comfortable&#8221; level. The use of spherical harmonics in graphics does not require comprehensive knowledge of the maths that underpins them, but it&#8217;s definitely a step up from what was required of a programmer in a younger industry.</p>
<p>To add some context, it&#8217;s worth noting that the use of spherical harmonics in lighting is now several years old. By industry standards spherical harmonics are by no means a new thing. I&#8217;d hazard this is evidence of their mathematical complexity reaching beyond what the industry is truly comfortable with handling. </p>
<p>Spherical harmonics are definitely not the most complex mathematical model in graphics. To use a more recent example: In the ShaderX7 Shadows section there&#8217;s a really excellent paper by <a href="http://www.cs.ucf.edu/%7Ecolbert/">Mark Colbert</a> and <a href="http://www.graphics.cornell.edu/%7Ejaroslav/">Jaroslav Křivánek</a>, <a href="http://www.mcl.ucf.edu/shaderx7/">&#8220;Real-time dynamic shadows for image-based lighting&#8221;</a>. I won&#8217;t go into the implementation details here, but suffice to say it&#8217;s non-trivial. It requires familiarity with some fairly advanced linear algebra, a very sound knowledge of sampling, and solving some fiddly least-squares problems with some interesting regularisation to prevent overfitting. It&#8217;s not dissimilar to the level of complexity of your typical SIGGRAPH paper.</p>
<p><a href="http://www.mcl.ucf.edu/shaderx7/"><img src="http://www.palgorithm.co.uk/wp-content/uploads/2009/04/mark-relighting.png" alt="mark-relighting" title="mark-relighting" width="495" height="248" class="aligncenter size-full wp-image-181" /></a><br />
<br />It&#8217;s a pretty steep learning curve these days. </p>
<p>(Get your proposals in!)</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.palgorithm.co.uk/2009/04/maths-and-shaderx8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My eyes! My eyes!</title>
		<link>http://www.palgorithm.co.uk/2008/12/my-eyes-my-eyes/</link>
		<comments>http://www.palgorithm.co.uk/2008/12/my-eyes-my-eyes/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 22:01:14 +0000</pubDate>
		<dc:creator>Sam Martin</dc:creator>
				<category><![CDATA[experiments]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[pov]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://www.palgorithm.co.uk/?p=89</guid>
		<description><![CDATA[This is the eye-candy equivalent of munching too many wham bars. It&#8217;s so simple I can&#8217;t help but love it, cheesy as it is.
Before I explain what&#8217;s going on &#8211; although you can probably guess &#8211; have a go at staring at the applet below. If there&#8217;s a big &#8220;P&#8221; then it&#8217;s still loading. If [...]]]></description>
			<content:encoded><![CDATA[<p>This is the eye-candy equivalent of munching too many wham bars. It&#8217;s so simple I can&#8217;t help but love it, cheesy as it is.</p>
<p>Before I explain what&#8217;s going on &#8211; although you can probably guess &#8211; have a go at staring at the applet below. If there&#8217;s a big &#8220;P&#8221; then it&#8217;s still loading. If there&#8217;s no applet&#8230; well, email me your browser, etc, etc and I&#8217;ll try and fix it.</p>
<p><b>Instructions:</b></p>
<ol>
<li>Get really close to the screen
<li>Stare at the flashing square in the middle of the crazy-colour image. <b>Don&#8217;t blink or move your eyes!</b>
<li>Count a good few flashes. 8-10 flashes should give you a good burn-in.
<li>Click the mouse button
<li>:O !
<li>Rinse and repeat
</ol>
<p>Processing-based Java applet:<br />
<object classid="java:sketch_colour_pov.class" type="application/x-java-applet" archive="http://palgorithm.co.uk/applets/colour_pov/sketch_colour_pov.jar" width="495" height="495" standby="Loading Processing software..." ><param name="archive" value="http://palgorithm.co.uk/applets/colour_pov/sketch_colour_pov.jar" /><param name="mayscript" value="true" /><param name="scriptable" value="true" /><param name="image" value="http://palgorithm.co.uk/applets/colour_pov/loading.gif" /><param name="boxmessage" value="Loading Processing software..." /><param name="boxbgcolor" value="#FFFFFF" /><param name="test_string" value="outer" /><object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab" width="495" height="495" standby="Loading Processing software..." ><param name="code" value="sketch_colour_pov" /><param name="archive" value="http://palgorithm.co.uk/applets/colour_pov/sketch_colour_pov.jar" /><param name="mayscript" value="true" /><param name="scriptable" value="true" /><param name="image" value="http://palgorithm.co.uk/applets/colour_pov/loading.gif" /><param name="boxmessage" value="Loading Processing software..." /><param name="boxbgcolor" value="#FFFFFF" /><param name="test_string" value="inner" /><p><strong>This browser does not have a Java Plug-in. <br /><a href="http://www.java.com/en/download/" title="Download Java Plug-in">Get the latest Java Plug-in here.</a></strong> </p>
<p></object></object></p>
<p>r0&#215;0r!</p>
<p>The effect can last for a surprising amount of time, providing you keep your eyes completely fixed on the square. The second you move them, something in your eyes and brain puts the internal window screen wipers on and it&#8217;s lost. At least for me, it seems that holding a fixed-view is more important than the length of time you stare. You can get a reasonable after image from a pretty quick glance providing you don&#8217;t look around the screen. </p>
<p>Most people are familiar with &#8220;persistence of vision&#8221;, as it&#8217;s known, through looking at light bulbs for too long, their tellies refresh rate, helicopter blades turning into a blur, and cool gadgets like <a href="http://www.ladyada.net/rant/2008/11/spoke-o-dometer-pov/">this</a>. It&#8217;s likely that the colour burn-in aspect of POV doesn&#8217;t have quite as many real applications as the &#8220;things moving too quick to see&#8221; aspect, so I expect the applet above will come as a happy surprise to at least a few people. </p>
<p>Question is: Is it useful? Well, I reckon it might be in the right setting, but for someone working in graphics/lighting it&#8217;s at least something to be aware of. I was shown this effect by <a href="http://www.jermilex.com/">Jeremy Vickery</a>, an ex-Pixar lighting artist while on a visit to Geomerics, so I&#8217;d expect the film industry is already well aware of it. He demoed it to us in a regular powerpoint slide as one of several examples of how crazy and unpredictable your eyes/brain can be. You eyes just lie, frankly. If you are interested you can get further details from his <a href="http://www.thegnomonworkshop.com/dvds/jvi01.html">DVD</a> and likely find his GDC &#8220;Practical Light and Color&#8221; talk slides on the net.</p>
<p>The question is, can this effect be used to good effect in games/films? I&#8217;m open minded to this possibility, but still thinking about it. There are definitely other tricks-of-the-eye that are relevant to film makers. In films you have robust control over what comes next. Games? Maybe. Still thinking.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.palgorithm.co.uk/2008/12/my-eyes-my-eyes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
