<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Displayhack</title>
	
	<link>http://www.displayhack.org</link>
	<description>Because code is beautiful</description>
	<lastBuildDate>Thu, 16 Feb 2012 10:12:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/displayhack" /><feedburner:info uri="displayhack" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>displayhack</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Sculpting In ZBrush 101 – Part 2</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/-HRaS36J4Ss/</link>
		<comments>http://www.displayhack.org/2012/sculpting-in-zbrush-101-part-2/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 10:10:15 +0000</pubDate>
		<dc:creator>Mathias Tangen Leganger</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[modelling]]></category>
		<category><![CDATA[sculpting]]></category>
		<category><![CDATA[series]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zbrush]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=1404</guid>
		<description><![CDATA[

Welcome back! In this part we will start sculpting a humanoid character using ZSpheres. ZSpheres is a very useful (and powerful) tool in that it offers you a super-fast and highly flexible way of getting starting the sculpting process (often the hardest part). This means that you don't have to create a base mesh ...]]></description>
			<content:encoded><![CDATA[<div class="alert white">Note: this is a series of articles on sculpting in ZBrush. You can <a href="http://www.displayhack.org/2011/sculpting-in-zbrush-101-part-1/‎">find part one here</a>.</div>
<p>Welcome back! In this part we will start sculpting a humanoid character using <a href="http://www.pixologic.com/docs/index.php/ZSpheres">ZSpheres</a>. ZSpheres is a very useful (and powerful) tool in that it offers you a super-fast and highly flexible way of getting starting the sculpting process (often the hardest part). This means that you don&#8217;t have to create a base mesh in a 3D-modeling package first, you can just hit the ground running. So, let&#8217;s get started!</p>
<h3>ZSpheres</h3>
<p>Open the ZBrush application and create a new document. Hit the <em>SimpleBrush</em> icon in the <em>Tool </em>menu, and then the <em>ZSphere</em> icon as shown in the picture below.</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/wp-content/uploads/zsphere-01.jpg"><img class="aligncenter size-full wp-image-1405" src="http://www.displayhack.org/wp-content/uploads/zsphere-01.jpg" alt="" width="316" height="280" /></a></p>
<p>Click and drag with LMB to draw the ZSphere on the canvas. Your screen should look like the picture below. Hit T to enter edit mode. Forget hitting T now and you will draw a new sphere every time you click on the canvas. If your accidentally draw new spheres, hit CTRL+N to clear the canvas, LMB-click-and-drag a new sphere, hit T, and you are OK.</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/wp-content/uploads/zsphere-02.png"><img class="aligncenter size-full wp-image-1406" src="http://www.displayhack.org/wp-content/uploads/zsphere-02.png" alt="" width="318" height="283" /></a></p>
<p>The red ball you have no drawn on the canvas is your root ZSphere, to which you now can add new ZSpheres (in a tree-like structure that branches out from the root). All you have to do is add new spheres, and adjust the position, scale, and rotation of each while looking at your shape from different angles. Your goal is to create a structure in this manner that resembles a basic foundation for the shape you have in mind, which you will use for starting the sculpting process.</p>
<p>Here are the actions you need to create a base mesh using ZSpheres:</p>
<ul>
<li><strong>Add new sphere:</strong> Hit Q to draw sphere. LMB-click-and-drag on a location on the sphere where you want to add a new one. Hold SHIFT if you want the new sphere to have the same size as its parent.</li>
<li><strong>Delete sphere: </strong>Hit ALT+LMB.</li>
<li><strong>Move sphere: </strong>Hit W to move sphere.</li>
<li><strong>Scale sphere:</strong> Hit E to resize.</li>
<li><strong>Rotate sphere:</strong> Hit R to rotate.</li>
<li><strong>Enable symmetry: </strong>Hit X.</li>
<li><strong>Preview: </strong>Hit A to preview the result.</li>
</ul>
<p>So, as I said the the beginning, we&#8217;re going to sculpt a humanoid character. The way to do that is to use ZSpheres to create a shape like the one on the left in the picture below, and then proceed to make ZBrush convert the ZSphere object into a polygon mesh for sculpting (shown to the right).</p>
<p style="text-align: center;">
<h3>The process</h3>
<p>To create a base mesh using ZSpheres, you can use the following steps and repeat until you are satisfied with how your preview looks:</p>
<ol>
<li>Add a new sphere on an existing one (or create a root sphere).</li>
<li>Move, scale, or rotate this new sphere while looking at your mesh from all views. (Enable symmetry if needed.)</li>
</ol>
<p>The picture below demonstrates the process used for creating a humanoid shape. (Remember to look at the object from all sides and not only the front view!)</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/wp-content/uploads/zsphere-04-1024x405.png"><img class="aligncenter size-large wp-image-1412" src="http://www.displayhack.org/wp-content/uploads/zsphere-04-1024x405.png" alt="" width="614" height="243" /></a></p>
<p style="text-align: left;">OK, so you have followed the process through several iterations and are satisfied with the preview. Time to convert to polygons!<br />
Navigate to <em>Adaptive skin</em> in the <em>Tool</em> menu and hit <em>Make adaptive skin</em>. The polygon mesh will now be added to your tool menu, named <em>Skin_&#8230;</em> Select it and start sculpting! :)</p>
<p style="text-align: center;"><a href="ttp://www.displayhack.org/wp-content/uploads/zsphere-05.png"><img class="aligncenter size-full wp-image-1413" src="http://www.displayhack.org/wp-content/uploads/zsphere-05.png" alt="" width="422" height="367" /></a></p>
<p>That concludes this part. Feel free to add comments or pictures of your works in the <a href="http://www.displayhack.org/forums/topic/sculpting-in-zbrush/">forums</a>. Have fun sculpting! :)</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=1404&amp;md5=26984c55b06aadfeb7163405b9c4ea19" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/-HRaS36J4Ss" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2012/sculpting-in-zbrush-101-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2012/sculpting-in-zbrush-101-part-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sculpting-in-zbrush-101-part-2</feedburner:origLink></item>
		<item>
		<title>Sculpting In ZBrush 101 – Part 1</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/7bF7jp1GC8g/</link>
		<comments>http://www.displayhack.org/2011/sculpting-in-zbrush-101-part-1/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 18:24:36 +0000</pubDate>
		<dc:creator>Mathias Tangen Leganger</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[modelling]]></category>
		<category><![CDATA[sculpting]]></category>
		<category><![CDATA[series]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zbrush]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=1260</guid>
		<description><![CDATA[
Hi and welcome to this series on sculpting in Pixologic ZBrush. In this series, we will investigate some of the game-changing techniques that have made ZBrush so popular among digital artists.

First, a quick primer on what ZBrush is. ZBrush is a digital sculpting and painting application (Autodesk Mudbox is another software package that offers ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><img class="aligncenter size-large wp-image-1295" src="http://www.displayhack.org/wp-content/uploads/dh_zbrush101_p1_worksnap-1024x627.png" alt="" width="540" height="331" /></p>
<p>Hi and welcome to this series on sculpting in <a href="http://www.pixologic.com/zbrush/features/zbrush4/overview/">Pixologic ZBrush</a>. In this series, we will investigate some of the game-changing techniques that have made ZBrush so popular among digital artists.</p>
<p>First, a quick primer on what ZBrush is. ZBrush is a digital sculpting and painting application (<a href="http://usa.autodesk.com/adsk/servlet/pc/index?id=13565063&amp;siteID=123112">Autodesk Mudbox</a> is another software package that offers similar capabilities). 3D sculpting means that you work on &#8220;digital clay&#8221;. You start out with a clay-like basic shape, like a sphere, and then you use a set of brushes to &#8220;sculpt&#8221; that clay. What makes ZBrush so powerful is that you can work on millions of polygons. In short, 3D sculpting is a very efficient and fun way to create high-polygon 3D models and/or normal-maps.</p>
<p>OK, enough with the sales pitch: let&#8217;s get to it!</p>
<p>There are basically two ways to start sculpting in ZBrush. One: make a simple &#8220;base mesh&#8221; in an external 3D application (such as Maya). Two: start with a simple shape or ZSpheres. ZSpheres are very cool, and we will save them for a later tutorial. In this part of the series we will start by importing a base mesh from Maya. You can refer to this <a href="http://www.displayhack.org/2011/maya101-1/">tutorial</a> if you need a refresher on Maya.</p>
<h3>Creating a base mesh</h3>
<p>There are basically three criteria for the base mesh:</p>
<ol>
<li>Keep it simple</li>
<li>Shape it into a very abstract representation of your design</li>
<li>Make sure the mesh is clean and quads only</li>
</ol>
<p>So, you may either have some concept drawings or a mental image as reference for your design. Then, block out a simple mesh in Maya that resembles that design, using only a handful of polygons. Now, this is very important: keep it clean and all quads. You will face quirky problems in ZBrush if your mesh does not satisfy this condition. All quads means that each polygon should have four edges (this has to do with the subdivison algorithms in ZBrush). Also: the mesh should not contain any holes, gaps, overlapping vertices or polygons with flipped normals. A good reference might be the section on <a href="http://www.displayhack.org/2011/maya101-1/">cleaning up the mesh</a> in my Maya tutorial series.</p>
<p>In the image below, I have created a base mesh for &#8220;Headmistress Daggerhorn&#8221;, which is one of the key characters featured in the game <a href="http://www.eviljunior.com/">Evil Junior</a> which I&#8217;m currently working on. It was created on top of great concept art from <a href="http://www.atleart.com/">Atle Mæland</a> as the reference.</p>
<p style="text-align: center"><img class="aligncenter size-full wp-image-1263" src="http://www.displayhack.org/wp-content/uploads/dh_zbrush101_p1_maya_01.png" alt="" width="211" height="270" /></p>
<p style="text-align: left">Create your own base mesh, and then export your base mesh as .OBJ in Maya. Brace for impact in ZBrush!</p>
<h3 style="text-align: left">Intro to ZBrush</h3>
<p>Time to open ZBrush. Hit &#8220;Import&#8221; in the tool menu and browse to your .OBJ base-mesh. &#8220;Draw&#8221; your base mesh onto the canvas by click-dragging in the viewport. Then hit &#8220;T&#8221; to edit the object.</p>
<p>Now, a brief heads-up on the ZBrush interface (see the picture below). To your right you will find the &#8220;Tool&#8221; and &#8220;Geometry&#8221; menu. Current brushes and materials are located to the left. Here is what you need to know:</p>
<ul>
<li><strong>Tool: </strong>Here you &#8220;Import&#8221; your base mesh. You save your work as ZTools by hitting &#8220;Save As&#8221;. Saved ZTools are loaded with &#8211; surprise! &#8211; &#8220;Load Tool&#8221;.</li>
<li><strong>SubTool: </strong>You can also import several sub tools and append them to your main tool, so that you can more easily hide and select individual objects on screen.</li>
<li><strong>Geometry: </strong>ZBrush &#8220;subdivides&#8221; your mesh when you hit &#8220;Divide&#8221;. Each division operation adds resolution to your mesh, measured as the number of &#8220;active points&#8221; in the HUD of the viewport. You can easily jump between subdivision levels by hitting &#8220;Lower Res&#8221; and &#8220;Higher Res&#8221;.</li>
<li><strong>Brush and material:</strong> Here you can edit your current settings for brushes and materials.</li>
</ul>
<p style="text-align: center"><img class="aligncenter" src="http://www.displayhack.org/wp-content/uploads/dh_zbrush101_p1_zbrush_01.png" alt="" width="406" height="381" /></p>
<p>ZBrush both looks and feels like something out of this world. (You will probably either love or hate the interface.) I would highly recommend you to use a pressure-sensitive pen and tablet for sculpting in ZBrush. Here is how to navigate:</p>
<ul>
<li><strong>Sculpt:</strong> LMB onto the mesh.</li>
<li><strong>Smooth:</strong> SHIFT+LMB onto the mesh.</li>
<li><strong>Quick-menu:</strong> RMB.</li>
<li><strong>Move: </strong>ALT+LMB in the background.</li>
<li><strong>Rotate:</strong> LMB in the background.</li>
<li><strong>Zoom:</strong> ALT+LMB in the background, then release ALT and hold LMB.</li>
<li><strong>Snap rotation into orthogonal view: </strong>Rotate and then hold SHIFT.</li>
</ul>
<p>Here are a few hints to kickstart the sculpting process:</p>
<ul>
<li><strong>Symmetry. </strong>Hit &#8220;X&#8221; to enable automatic mirroring.</li>
<li><strong>LazyMouse: </strong>Hit <em>Stroke -&gt; LazyMouse </em>to enable computer-aided stability to your strokes. Hands like a surgeon!</li>
<li><strong>Brushes: </strong>Some brushes you may find useful are the <em>Standard</em>, <em>Smooth</em>, <em>Move</em>, <em>mPolish</em>, and <em>Slash</em> brushes.</li>
<li><strong>Strokes and alphas: </strong>Try experimenting with these to customize your brushes. You can add high-res details by painting an alpha in Photoshop and then apply it to your mesh using the <em>Drag Rect</em> stroke.</li>
<li><strong>Material: </strong>Try using other materials other than the very &#8220;ZBrushish&#8221; <em>MatCap Red. </em>All the MatCap materials are good. Switch between them to apply different effects to your mesh. <em><br />
</em></li>
<li><strong>Iterate: </strong>This is perhaps the most important thing in ZBrush. Only subdivide your mesh when you have maxed-out the current level of resolution. Iterate and add more detail for each subdivision level.</li>
<li><strong>Reference: </strong>The use of reference (anatomy guides, bodybuilding magazines, images on the web) can make all the difference. Study the anatomy of bones and muscle if you find the time. Be aware of nudity though.</li>
<li><strong>Masking:</strong> Hit CTRL+LMB or ALT+LMB onto the mesh to paint masks. Very powerful for adding details. You have more options under the &#8220;Masking&#8221; menu.</li>
</ul>
<h3>Basic sculpting in ZBrush</h3>
<p>The sculpting process in ZBrush is actually very simple. It all boils down to iteration. In the beginning of the sculpting process, try using the <em>Move</em> brush to drag the mesh into the shape you want. You can also ALT+LMB with this brush to push or pull. When you are satisfied with the overall shape, use the <em>Standard </em>brush with LMB and ALT+LMB to paint detail at the surface. Use the <em>Smooth </em>brush in between to make the surface nice and clean. (You may want to dial down the brush modifier on the <em>Smooth </em>brush to make it less sensitive.) When you are happy with your sculpting at this level, subdivide and repeat the sculpting process. You can keep on subdividing like this till you drop &#8211; or more probably &#8211; you run out of RAM. Two million polygons should suffice &#8211; any more than that and your RAM will probably choke. As I gradually add more and more resolution for each iteration, I tend to use the brushes in the following manner:</p>
<ul>
<li><strong>Move</strong>: I use this mostly at low resolutions to pull and push the clay into shape.</li>
<li><strong>Standard</strong>: This brush I tend to use at all resolutions, gradually decreasing the brush size for each subdivision.</li>
<li><strong>Smooth</strong>: I use this ALL the time.</li>
<li><strong>mPolish</strong>: Great to use at higher resolutions to flatten out a surface. Especially if you aim for a cartoony look.</li>
<li><strong>Slash</strong>: At very high resolutions you can use this brush to add scars and such.</li>
<li><strong>Pinch</strong>: Very nice for pulling two edges towards each other, for example if you want to &#8220;tighten&#8221; a scar.</li>
</ul>
<p>In the picture below you can see how Daggerhorn takes shape from a simple base mesh to a high-ploygon bust of the Headmistress of Gloomcraft Academy.</p>
<p><span><a href="http://www.displayhack.org/2011/sculpting-in-zbrush-101-part-1/dh_zbrush101_p1_zbrush_process/" rel="attachment wp-att-1283"><img class="aligncenter size-medium wp-image-1283" src="http://www.displayhack.org/wp-content/uploads/dh_zbrush101_p1_zbrush_process-543x250.png" alt="" width="543" height="250" /></a></span></p>
<h3>That&#8217;s it</h3>
<p>Piece of cake. Now, post an image of your sculpt in the <a href="http://www.displayhack.org/forums/forum/gallery/">gallery</a> and stay tuned for the next installment! See you around :)</p>
<p>Oh, and one last thing: Here is an all-exclusive and yet unreleased work-in-progress of Headmistress Daggerhorn from <a href="http://www.eviljunior.com/">Evil Junior</a>!</p>
<p style="text-align: center"><img class="aligncenter size-large wp-image-1288" src="http://www.displayhack.org/wp-content/uploads/dh_zbrush101_p1_zbrush_dhorn-1024x650.png" alt="" width="614" height="390" /></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=1260&amp;md5=f99c31ecfd9926c9573fecf0586547f0" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/7bF7jp1GC8g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/sculpting-in-zbrush-101-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/sculpting-in-zbrush-101-part-1/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sculpting-in-zbrush-101-part-1</feedburner:origLink></item>
		<item>
		<title>Superpacking JS demos</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/sWFTWiY_k40/</link>
		<comments>http://www.displayhack.org/2011/superpacking-js-demos/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 07:55:55 +0000</pubDate>
		<dc:creator>Cody Brocious</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[1k]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=1211</guid>
		<description><![CDATA[The techniques I'm going to be describing here were created and/or implemented to pack my entry to the Mozilla Demoparty: Magister. Huge thanks to my friend Nicolás Alvarez for helping squeeze every last byte out of this.
Getting started
So you have a demo in JS. It's pretty. It's perfect. It's 3k in a 1k competition. Well, damn.

You ...]]></description>
			<content:encoded><![CDATA[<p>The techniques I&#8217;m going to be describing here were created and/or implemented to pack my entry to the <a href="https://demoparty.mozillalabs.com/">Mozilla Demoparty</a>: <a href="http://pouet.net/prod.php?which=57308">Magister</a>. Huge thanks to my friend Nicolás Alvarez for helping squeeze every last byte out of this.</p>
<h3>Getting started</h3>
<p>So you have a demo in JS. It&#8217;s pretty. It&#8217;s perfect. It&#8217;s 3k in a 1k competition. Well, damn.</p>
<p>You start with the obvious and run it through a minifier and you shorten all your variable names to a single character, you get it to 2500 bytes. Great, that&#8217;s progress, but you&#8217;ve still got 1476 bytes to go. You merge some functions together, fold a couple loops into each other, and soon you&#8217;re at 2200 bytes. Long way to go.</p>
<p>Rule #1 of shrinking demos: removing a byte becomes more difficult every time you remove a byte. It starts off trivial and runs very quickly into a brick wall.</p>
<h4>Quick wins</h4>
<p>These are a couple useful techniques to trim the fat at this point.</p>
<pre class="brush: jscript; title: ; notranslate">var a = g.getAttribLocation(x, 'pos');
g.uniform1f(g.getUniformLocation(x, 'time'), t);
g.vertexAttribPointer(a, 2, g.FLOAT, 0, 0, 0);
g.enableVertexAttribArray(a);</pre>
<p>What&#8217;s wrong with this picture? Well, if we ignore whitespace (minification takes care of that): we&#8217;re using <strong>var</strong> (pfft, correctness), we have a shader attribute with a 3-byte name and a uniform with a 4-byte name, we&#8217;re using g.FLOAT (more on this in a moment), and we&#8217;ve got a lot of zeros.</p>
<pre class="brush: jscript; title: ; notranslate">g.vertexAttribPointer(
    a = g.getAttribLocation(x, 'p'),
    2,
    5126,
    g.uniform1f(g.getUniformLocation(x, 't'), z),
    0,
    0
)</pre>
<p>Much better! We killed <strong>var</strong> removing 4 bytes, we removed 2 bytes by inlining the assignment to <strong>a</strong> in the first use and killing the semicolon, we eliminated a zero (the return of uniform1f is treated as a zero by the WebGL API in this case) and a semicolon for a savings of 2 bytes, we changed our shader attributes/uniforms to have 1-byte names (saving 5 bytes), and we inlined the FLOAT constant for a savings of 3 bytes. That&#8217;s 16 bytes removed from a block of 151 (after whitespace removal), or a reduction by 10.59%! Let&#8217;s do it again.</p>
<p>Before we move on, I just want to make a note that WebGL constants really are just that. You can inline them and trust them not to change.</p>
<h4>Abusing globals</h4>
<p>Look at the latest code above. Count the instances of &#8216;g.&#8217;. Four instances just in that tiny little snippet. If we could get rid of those in a small way, this could be a huge win, so let&#8217;s do it.</p>
<p>What is the global namespace in JS? Normally, it comes from the <strong>window</strong> object. So when you call <strong>foo()</strong>, it&#8217;s going to look in <strong>window</strong> if you haven&#8217;t declared it locally. So why don&#8217;t we shove our methods into the <strong>window</strong> object? Or even better, into <strong>top</strong> (in our case, they&#8217;re identical)?</p>
<p>Right now the declaration of <strong>g</strong> is as such:</p>
<pre class="brush: jscript; title: ; notranslate">g = z.getContext('experimental-webgl')</pre>
<p>But let&#8217;s change it to:</p>
<pre class="brush: jscript; title: ; notranslate">for(k in g = z.getContext('experimental-webgl'))
    top[k] = g[k].bind &amp;amp;&amp;amp; g[k].bind(g);</pre>
<p>So we walk over every key in the WebGL context and put it into <strong>top</strong>, but only if it has the bind method and we can bind it to the WebGL context. Without that, it tries to treat the window as a WebGL context. The window doesn&#8217;t like this.</p>
<p>At this point, we just cut all instances of &#8216;g.&#8217; out of the picture. This was a win of around 30 bytes (counting the cost of the globalization code) in my demo&#8217;s case, but we can go much, much further.</p>
<h3>What&#8217;s in a name?</h3>
<p>Let&#8217;s look at a list of all the WebGL methods I called in my demo:</p>
<div>
<div>
<pre>
attachShader
createProgram
linkProgram
createBuffer
bindBuffer
bufferData
viewport
createShader
shaderSource
compileShader
useProgram
getAttribLocation
getUniformLocation
uniform1f
uniform2f
vertexAttribPointer
enableVertexAttribArray
drawArrays
</pre>
</div>
</div>
<p>Holy moly, that&#8217;s a lot of bytes! But these are defined in WebGL, how can we change this?</p>
<p>Welllll&#8230; let&#8217;s look back at our globalization code. We get a name, <strong>k</strong>, and then bind <strong>g[k]</strong> into<strong>top[k]</strong>. But we control what <strong>k</strong> goes into <strong>top</strong>. Having a map of long name into short name would be expensive, but what about a regex? I&#8217;m going to spare you the gory details, but after a while of tinkering with it, I determined that the optimal code for this is:</p>
<div>
<div>
<pre>t[k.slice(1, -5).replace(/[ntalruicoh]/ig, '')] = t[k] = g[k].bind &#038;&#038; g[k].bind(g);
</pre>
</div>
</div>
<p>In this case, <strong>t</strong> is <strong>top</strong> (because hey, 4 bytes!). We still assign the original name into <strong>t</strong>, but we also put the sliced and diced name into it. Why? Because this mangles two names we need to disambiguate: <strong>uniform1f</strong> and <strong>uniform2f</strong>. But that&#8217;s fine.</p>
<p>So what do the names look like after this?</p>
<div>
<div>
<pre>S
eeP
kP
eeB
dB
ffe
e
eeS
deS
mpeS
seP
eb
efm
f
f
eexbP
beVeexb
w
</pre>
</div>
</div>
<p>Night and day difference, as you can see. You&#8217;ll obviously want to change the regex if you do this yourself, since your code will have different balances.</p>
<h4>Other random wins</h4>
<p>Arrays of digits tend to be pretty wasteful:</p>
<pre class="brush: jscript; title: ; notranslate">new Float32Array([0,0,2,0,0,2,2,0,2,2,0,2])</pre>
<p>What about this instead?</p>
<pre class="brush: jscript; title: ; notranslate">new Float32Array('002002202202'.split(''))</pre>
<p>The more digits you have, the bigger the win from this replacement is. Until we get to compression and everything changes.</p>
<h3>Compression</h3>
<p>Ok, we all know HTTP requests are trivially compressible, and this can improve load times and blah blah blah. Doesn&#8217;t matter when it comes to demos: if the size on the wire is 1k and the size on disk is 3k, your demo is 3k.</p>
<p>In the past, people have compressed their demos into images. This is an easy way to get a good size reduction &#8212; PNGs are just zlib&#8217;d data with a little header, basically. But these demos all had a PNG and an HTML+JS file that would load the PNG, draw it to a canvas, pull the pixels out of the canvas as a string, and eval that string. How can you make this into a single file demo?</p>
<h4>Introduction to PNGs</h4>
<p>The PNG file has an 8-byte signature followed by a series of simple chunks. The chunk format is as follows:</p>
<pre class="brush: plain; title: ; notranslate">4 byte length
4 byte chunk type
&amp;lt;length&amp;gt; byte chunk data
4 byte CRC</pre>
<p>Most of these are pretty clear, except chunk type. Chunk type is a FourCC, e.g. &#8216;IHDR&#8217;, which is mostly generic, with some exceptions which I&#8217;ll talk about shortly.</p>
<p>I&#8217;m not going to go into detail on the IHDR chunk (we can&#8217;t really mess with it, but I will say I use greyscale for simplicity purposes), but here&#8217;s what we start with.</p>
<pre class="brush: plain; title: ; notranslate">8 byte signature
13 byte IHDR with 12 byte chunk header
X byte IDAT (covered below) with a 12 byte chunk header</pre>
<p>The IDAT format is dead simple: 1 byte filtering method followed by your zlib deflated data.</p>
<h4>Abusing PNGs</h4>
<p>We start by defining our own chunk type (we&#8217;re allowed to do that!) before the IDAT chunk.</p>
<pre class="brush: plain; title: ; notranslate">4 byte length
4 byte &amp;quot;jawh&amp;quot; (Just Another WebGL Hacker (TM))
X byte bootstrap
4 byte CRC</pre>
<p>What is the bootstrap? Well, it&#8217;s what turns our PNG into code and runs it. Here&#8217;s the one I use:</p>
<pre class="brush: jscript; title: ; notranslate">&amp;lt;img onload=with(document.createElement('canvas'))p=width=4968,(c=getContext('2d')).drawImage(this,e='',0);
while(p)e+=String.fromCharCode(c.getImageData(0,0,p,1).data[p-=4]);
(t=top).eval(e) src=#&amp;gt;</pre>
<p>The 4968 here is really the size of the decompressed data in bytes times 4 &#8212; there are 4 components to each pixel (red, green, blue, alpha) but we&#8217;re only using grayscale, so we need to offset that. If you look carefully, you&#8217;ll also notice that it walks backwards across the data, which should create a string in reverse, but I compensate for that when I compress the data, and reverse it before doing so. This saves a couple bytes. The image source is also important: rather than hard-coding the image filename and wasting space, it uses <strong>#</strong>, enabling it to treat itself as a PNG.</p>
<p>So what do we have now? We have a PNG containing some HTML. The browser first opens it as HTML (file extension is important here), then sniffs the MIME type and figures out it&#8217;s a PNG when it gets loaded into the image tag. We have a self-extracting PNG. But we can do better.</p>
<h4>Why specs don&#8217;t matter</h4>
<p>We&#8217;re currently using a chunk type of &#8220;jawh&#8221;. Clever and a nice little insider reference, but that&#8217;s 4 wasted bytes! The chunk type comes right before the data, so why don&#8217;t we make the chunk type into <strong>&lt;img</strong> instead?</p>
<p>The spec says on the subject:</p>
<blockquote><p>Four bits of the type code, namely bit 5 (value 32) of each byte, are used<br />
to convey chunk properties. This choice means that a human can read off the<br />
assigned properties according to whether each letter of the type code is<br />
uppercase (bit 5 is 0) or lowercase (bit 5 is 1). However, decoders should<br />
test the properties of an unknown chunk by numerically testing the specified<br />
bits; testing whether a character is uppercase or lowercase is inefficient,<br />
and even incorrect if a locale-specific case definition is used.</p></blockquote>
<p>It then goes on to tell you that bit 5 of each of the bytes is:</p>
<blockquote><p>First byte: 0 = critical, 1 = ancillary<br />
Second byte: 0 = public, 1 = private<br />
Third byte: reserved<br />
Fourth byte: 0 = unsafe to copy, 1 = safe to copy</p></blockquote>
<p>Since we could call it <strong>&lt;iMg</strong> or <strong>&lt;imG</strong> or any other combination of uppercase and lowercase, clearly we only care about the impact of <strong>&lt;</strong> on the first byte. But if we look at bit 5 of <strong>&lt;</strong>, we see that it&#8217;s already set high, so it&#8217;s an ancillary chunk &#8212; we&#8217;re in the clear and just saved 4 bytes!</p>
<p>Wait, no, neither Chrome nor Firefox load the image anymore. What the hell? This is the point where you realize: the spec doesn&#8217;t matter. No browser out there follows the PNG spec, whatsoever. Perfectly to-the-spec images won&#8217;t work, and horribly broken images will work. So let&#8217;s horribly break it. Note: Both Chrome and Firefox use libpng for image parsing, so you could go through the code and look for ways in which it&#8217;s mishandling data and go down that path, but for my purposes I found that just experimentally changing things and seeing how they break was Good Enough (TM).</p>
<h4>Breaking PNG for fun and profit</h4>
<p>Messing with the chunk type is out due to browser incompatibility, so what other options do we have? Well, who cares about CRCs.</p>
<p>Set the CRC to <strong>c=#&gt;</strong>, save, refresh. Hey, it works in Chrome and Firefox! 4 bytes saved.</p>
<p>Well, we can&#8217;t push back towards the front due to the chunk type, and we can&#8217;t push forwards towards the IDAT chunk because of the size. But how do browsers handle chunk size mismatches?</p>
<p>If we set the size of the IDAT atom to <strong>c=#&gt;</strong>, that unpacks to a size of 1042496867, which is obviously more than the size of the IDAT chunk. We shift <strong>) sr</strong> into the CRC and set the IDAT size to <strong>c=#&gt;</strong>, save, refresh. All browsers will set <strong>size = min(reportedSize, endOfFile &#8211; startOfChunk)</strong>! That saves us another 4 bytes.</p>
<p>So sure, we couldn&#8217;t get rid of <strong>jawh</strong>, but who cares? We just saved 8 bytes!</p>
<h4>Compression caveats</h4>
<p>Now you know how to make the PNG container small, but this says nothing about actually making your demo small. A few of the tips above are actually <em>harmful</em> in the context of compression. Why? Because repetitive data compresses really, really well. For instance, the Float32Array trick is nice when you&#8217;re dealing with uncompressed data, but ends up eating a couple extra bytes after compression. Reusing function and variable names is also very, very important. The more repetition you can introduce, the better off you&#8217;ll generally be.</p>
<h3>Wrapping up</h3>
<p>All in all, these tips (and general insanity) will let you build really small demos. My demo, Magister, went from around 3k down to just over 900 bytes when all was said and done. I ended up adding a message in the demo (&#8220;1k should be enough for anybody.&#8221;) to get it up to exactly 1024 bytes, which was my goal. Feels good to have to work up rather than down.</p>
<p>I hope this helped shine some light on the subject.</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=1211&amp;md5=24e751aa127320d846640822694215da" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/sWFTWiY_k40" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/superpacking-js-demos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/superpacking-js-demos/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=superpacking-js-demos</feedburner:origLink></item>
		<item>
		<title>Web demo goodies – August 2011</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/klDcHnLMs48/</link>
		<comments>http://www.displayhack.org/2011/web-demo-goodies-august-2011/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 05:32:33 +0000</pubDate>
		<dc:creator>Bent Stamnes</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=986</guid>
		<description><![CDATA[For this month's roundup of things moving and shaking on the web, we'll dip into the pool as well as reunite with our good old friend; the Cornell Box.

Above: Evan Wallace has once again created a much talked about tech-demo called, with great efficiency: WebGL Water. The tech demo features raytracing, soft shadows, caustics ...]]></description>
			<content:encoded><![CDATA[<p>For this month&#8217;s roundup of things moving and shaking on the web, we&#8217;ll dip into the pool as well as reunite with our good old friend; the Cornell Box.</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-1000" title="webgl_water" src="http://www.displayhack.org/wp-content/uploads/webgl_water-1024x641.jpg" alt="" width="614" height="385" /></p>
<p><strong>Above:</strong> <a href="http://madebyevan.com/">Evan Wallace</a> has once again created a much talked about tech-demo called, with great efficiency: <a title="WebGL Water by Evan Wallace" href="http://madebyevan.com/webgl-water/">WebGL Water</a>. The tech demo features raytracing, soft shadows, caustics and &#8220;analytic&#8221; (meaning &#8220;fake&#8221; :) ambient occlusion. It all comes together in an interactive WebGL app that looks good and has a very decent framerate, even on middle-of-the-road hardware. Well done!</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1004" title="webgl_path_tracer" src="http://www.displayhack.org/wp-content/uploads/webgl_path_tracer.jpg" alt="" width="575" height="362" /></p>
<p><strong>Above: </strong>Another piece from Evan Wallace, this time taking on <a title="WebGL Path Tracing by Evan Wallace " href="http://madebyevan.com/webgl-path-tracing/">path tracing</a> to create more realistic lighting and shadowing in a scene. The tech-demo allows you to change the material, move the lights and add/remove objects in the scene, as well as moving them around. Fun to play with, and again, surprisingly fast.</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-1011" title="nautilus" src="http://www.displayhack.org/wp-content/uploads/nautilus-1024x498.jpg" alt="" width="614" height="299" /></p>
<p><strong>Above: </strong><a title="MKVDB.com" href="http://www.mkvdb.com">MKVDB</a> has made a <a title="See the WebGL port online" href="http://www.mkvdb.com/webgl/webgl5.htm">WebGL port</a> of his native <a title="Download the 1k EXE for Windows" href="http://www.mkvdb.com/nautilus.zip">Windows 1k executable</a> &#8220;Nautilus&#8221; intro. Goes fullscreen and is a little heavy for most mid-range computers, but if you have a fast one it looks really gorgeous.</p>
<p style="text-align: center;"><img class="aligncenter size-large wp-image-1022" title="cadillac" src="http://www.displayhack.org/wp-content/uploads/cadillac-1024x565.jpg" alt="" width="614" height="339" /></p>
<p><strong>Above:</strong> The famous <a title="Wikipedia: Cadillac Ranch" href="http://en.wikipedia.org/wiki/Cadillac_Ranch">Cadillac Ranch art installation in Texas</a> has found a home online in the <a title="Virtual Cadillac Ranch" href="http://www.spacegoo.com/cadillac/">virtual Cadillac Ranch</a>. You can move around (granted, the controls are not exactly top notch) and spray-paint the car-wrecks in the sand. Built on WebGL.</p>
<div class="alert white">Note: starting from the next part in this series, it&#8217;ll go from a monthly to a weekly post, to keep up with all the awesome that happens online these days.</div>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=986&amp;md5=a311fa75b1f87526b0a71351f34dc653" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/klDcHnLMs48" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/web-demo-goodies-august-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/web-demo-goodies-august-2011/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=web-demo-goodies-august-2011</feedburner:origLink></item>
		<item>
		<title>Modelling in Maya 101 – Part 2</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/PNpgJN7FAiQ/</link>
		<comments>http://www.displayhack.org/2011/maya101-2/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 16:15:23 +0000</pubDate>
		<dc:creator>Mathias Tangen Leganger</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[maya]]></category>
		<category><![CDATA[modelling]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[texturing]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=751</guid>
		<description><![CDATA[
Welcome back! We created a character in part 1, using various 3D-modelling techniques inside of Maya (or your preferred modelling package). We now have our 3D-mesh and UV-layout ready to go, though our character looks kind of dull just with that default-gray Lambert-material in Maya.

Colors anyone?

In order to unleash your creativity and bring your character ...]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_nigel01/" rel="attachment wp-att-752"><img class="size-medium wp-image-752 aligncenter" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_nigel01-423x250.png" alt="" width="423" height="250" /></a></p>
<p><span>Welcome back! We created a character in <a href="http://www.displayhack.org/2011/maya101-1/">part 1</a>, using various 3D-modelling techniques inside of Maya (or your preferred modelling package). </span>We now have our 3D-mesh and UV-layout ready to go, though our character looks kind of dull just with that default-gray Lambert-material in Maya.</p>
<p>Colors anyone?</p>
<p>In order to unleash your creativity and bring your character to life, you need one (or several) texture maps. We will start out with the diffuse map. In a nutshell, the diffuse map is a 2D picture that gets projected onto your 3D mesh, telling your application (or game) what color should be assigned to which polygon. Similarly, you have tons of other possible maps for things such as specularity, transparency, bumps and what not. The picture above depicts the notorious Sir Nigel Rochester (known from &#8220;<a href="http://www.eviljunior.com/">Evil Junior</a>&#8221; of course) as a 3D mesh with a diffuse-map containing all of his color information.</p>
<p>Let&#8217;s see how you go about making one of those diffuse maps!</p>
<h3>Enter Photoshop</h3>
<p>Photoshop is perhaps <strong>the</strong> application for painting 2D texture-maps (but feel free to give me a shelling in the comments field if you disagree). You may absolutely use other packages (or even hand paint your textures and scan them) but in this tutorial series I&#8217;m going to stick to Photoshop. Many 3D packages also provide more or less useful texture-painting capabilities, most notably ZBrush and BodyPaint. I will actually showcase some techniques in BodyPaint later on, so stay tuned for that.</p>
<p>Back to the action &#8211; fire up Photoshop and create a new file. I recommend the following settings for your texture maps:</p>
<ul>
<li>Width x height: 2048 x 2048 pixels</li>
<li>Resolution: 300 pixels/inch</li>
<li>RGB Color with 8 bits</li>
</ul>
<p>This should result in a PSD file of ~12 MB. 2048 x 2048 pixels = &#8220;2K&#8221; in pixel-pusher lingo. 1024 = 1K. You get the idea. Now one piece of advice (which I learned for myself the hard way): don&#8217;t be cheap on your initial texture resolution &#8212; ever! By heeding this advice you will hopefully avoid the painful mistake of starting out with a texture resolution that is too low, only to find yourself starting from scratch because the texture you spent several hours working on looks blurry on your mesh. If your initial texture-file is 2K, you can always export your texture as 1K if need be. But a 1K master-file upscaled to a 2K texture map is surely an abomination.</p>
<p>Ok, so 2K should do for this project. Save the newly-created file as a PSD in the <em>sourceimages </em>directory of your Maya project. Name it something like: <em>yourcharacter_diffuse.PSD.</em></p>
<h3>Texturing preparations</h3>
<p>Now you should have a clean 2K-canvas facing you in Photoshop. Let&#8217;s go through a few hints before you continue on your texturing business.</p>
<p>First, make sure you have exported a &#8220;UV Snapshot&#8221; from the UV Texture Editor inside Maya, as depicted in the picture below. I will use this snapshot as reference in the painting process.</p>
<p style="text-align: center;"> <a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_uvsnap/" rel="attachment wp-att-768"><img class="size-medium wp-image-768 aligncenter" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_uvsnap.png" alt="" width="524" height="539" /></a></p>
<p style="text-align: left;">Next, you can either save your texture map during the process as an image file and insert it into your map in Maya (as we discussed under <em>&#8220;Assigning Maps&#8221;</em> in <a href="http://www.displayhack.org/2011/maya101-1/">part 1</a>) &#8212; or &#8212; you could utilize this nifty trick: create a new material in your Hypershade Editor in Maya by selecting &#8220;PSD File&#8221;. Browse to your PSD file in &#8220;Image Name&#8221;. Select your mesh in Maya, then RIGHT-CLICK the &#8220;place2dTexture&#8221; node in Hypershade and click &#8220;Assign texture&#8217;s material to selection&#8221; (see image below).</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_hshade/" rel="attachment wp-att-771"><img class="aligncenter size-large wp-image-771" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_hshade-1024x615.png" alt="" width="516" height="311" /></a></p>
<p>You should be able to save some time by hitting &#8220;Save&#8221; in Photoshop and see the PSD material instantly update inside Maya. With that out of the way, let&#8217;s set up some layers inside of Photoshop.</p>
<p>Layers are among the texture artist&#8217;s best friends: they help creative (and often disorganized) people be effective (and in the process: more organized). They eat RAM, so don&#8217;t go crazy on your layers. But a few will help you experiment and save you a lot of time. Remember that you may also be part of a team and that other artists may need to work on your files. How to win friends in the art department: keep your files clean, properly named and organized.</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_layers/" rel="attachment wp-att-775"><img class="aligncenter size-full wp-image-775" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_layers.png" alt="" width="462" height="339" /></a></p>
<p style="text-align: left;">The picture above shows my layers for Nigel&#8217;s PSD file.</p>
<ul>
<li>Put your UV snapshot at the top, with &#8220;normal&#8221; or &#8220;multiply&#8221; as the layer blending-mode.</li>
<li>Create a folder for ambient-occlusion effects. This is a very nice trick I will dive into next.</li>
<li>One folder for your &#8220;diffuse&#8221;, i.e. where you put all your paint layers.</li>
</ul>
<p>Alright, now let&#8217;s bake that ambient-occlusion map&#8230;</p>
<h3>Ambient occlusion</h3>
<p>This step is optional, but with the process being a snap and the results being good &#8212; why not give it a try?</p>
<p>Ambient occlusion (AO) is an effect in which you let the renderer determine shadows for you. A white material is applied to everything in the scene, and then the scene is lit. Lighting and shadow information is calculated and the renderer &#8220;bakes&#8221; an AO-map containing only shades of black and white. By doing this, you basically let the renderer figure out shadows on your mesh. It can really add that little extra and also save you a lot if time in the texturing process. Lazy artists are good artists. I will briefly walk you through the process of baking AO-maps in Maya right now..</p>
<p>Ok, so this is what we will do: open up your 3D mesh in Maya and apply the ambient-occlusion material in the Hypershade Editor:</p>
<ul>
<li>Create the surface shader: <em>Maya -&gt; Surface -&gt; Surface Shader.</em></li>
<li>Create the AO shader: <em>mental ray -&gt; Textures -&gt; mib_amb_occlusion.</em></li>
<li>Connect the AO to the surface shader in the Work Area by MMB-dragging AO output to surface input (see picture). Choose <em>default </em>(outValue -&gt; outColor).</li>
<li>Select the AO shader and open the Attribute Editor (CTRL+A).</li>
<li>Play with different settings under &#8220;Samples&#8221; (quality of output) and &#8220;Distance&#8221; (effect). Try setting &#8220;Samples&#8221; to 128 or 256.</li>
<li>Apply this material to your mesh.</li>
</ul>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_ao1-2/" rel="attachment wp-att-1062"><img class="aligncenter size-full wp-image-1062" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_ao11.png" alt="" width="545" height="382" /></a></p>
<p>Now we need to &#8220;bake&#8221; (or in other words: render) this texture:</p>
<ul>
<li>Select your perspective camera in the Outliner. In the Attribute Editor set <em>Environment -&gt; Background Color </em>to white.</li>
<li>Select <em>Rendering </em>in the menu selection.</li>
<li>Select <em>Render -&gt; Render using -&gt; mental ray </em>(you may need to enable mental ray in the plug-in manager) in the main menu.</li>
<li>Select your mesh.</li>
<li>Hit <em>Lighting/Shading -&gt; Batch Bake (mental ray) Settings. </em>Set the resolution to your texture map resolution, e.g. 2K.</li>
<li>Hit <em>Convert </em>when done.</li>
</ul>
<p>The resulting map will be baked to <em>renderData -&gt; mental ray -&gt; lightMap </em>in your project directory. The result should look something like this:</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_ao2/" rel="attachment wp-att-1063"><img class="aligncenter size-full wp-image-1063" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_ao2.png" alt="" width="429" height="334" /></a></p>
<p style="text-align: left;">Awesome. Now paste your freshly-baked AO-map onto its own layer in Photoshop, set the layer to &#8220;Multiply&#8221; and make sure it&#8217;s placed on top of any and all diffuse-layers you might already have. Adjust the blend-percentage to taste. Voilá!</p>
<h3>3D texture-painting in BodyPaint</h3>
<p style="text-align: left;">This step is optional but highly recommended if you have access to an application supporting 3D-painting. Painting a texture on a 2D canvas can be both limiting and frustrating because of distorted and slow feedback. 3D texture-painting enables a much more intuitive and responsive process because you paint directly onto the surface of the mesh. There are two methods for 3D-painting used by different solutions. ZBrush offers polygon-painting where you paint individual polygons directly. BodyPaint stores color information as an intermediary 2D-image. Maya also offers 3D-painting capabilities. I will use BodyPaint in this example. The principles are the same, regardless of application used. Here is what you need to do:</p>
<ul>
<li>Export the mesh you want to 3D-paint to an .OBJ file in Maya.</li>
<li>Open BodyPaint. Create a new project. Import your .OBJ file.</li>
<li>Select all mesh objects in the &#8220;Objects&#8221; tab.</li>
<li>Create a new material in the &#8220;Materials&#8221; tab. RIGHT-CLICK the new material and hit &#8220;Apply&#8221;.</li>
<li>Click on the material icon. In the &#8220;Attributes&#8221; tab click <em>Color -&gt; Texture -&gt; Create New Texture. </em>Alternatively, load your existing texture.</li>
<li>RIGHT-CLICK the material icon and hit &#8220;Enable 3D Paint&#8221;.</li>
<li>Create a new layer under the &#8220;Layers&#8221; tab.</li>
<li>Start painting!</li>
</ul>
<p>Now you can either make a texture from scratch or enhance your existing textures. 3D-painting is also great for painting in reference for 2D-painting. This is what I have done in the picture below. This way I can easily figure out where I want to paint Nigel&#8217;s shadows and skin in Photoshop.</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_bodypaint-2/" rel="attachment wp-att-1148"><img class="aligncenter size-full wp-image-1148" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_bodypaint1.png" alt="" width="427" height="323" /></a></p>
<p>When you are finished simply RIGHT-CLICK the texture icon next to the material under the &#8220;Material&#8221; tab and press <em>Texture -&gt; Save Texture as. </em>Save as .PSD if you want to keep your layers.</p>
<h3>Painting in Photoshop</h3>
<p>Contrary to popular belief, you don&#8217;t need a PhD in Photoshop in order to paint awesome textures. All you really need is the paint brush. Here are a few additional tricks you may find useful:</p>
<p><strong>Layer masks: </strong>Click in the background (outside the grid markings) in your UV-snapshot layer with the Magic Wand Tool (W). Click CTRL+SHIFT+I to invert the selection. Create a new layer. Then hit &#8220;Add layer mask&#8221; in the layers panel. You can see the result in the picture below. Next to the mini-version of your paint layer, you have a black-and-white representation of your layer mask. 100% black in the mask = 100% invisible, 100% white = 100% visible. In other words, layer masks are an extremely flexible and powerful tool in the painting process because you can &#8220;paint&#8221; in or out what should be visible in this particular layer. This is very nice when you want to blend your layers manually.</p>
<p><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_layermasks/" rel="attachment wp-att-1120"><img class="aligncenter" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_layermasks.png" alt="" width="172" height="272" /></a></p>
<p><strong>External textures: </strong>You can achieve insanely nice and lifelike effects by adding external textures and images onto a separate layer and experiment with the blending mode of the layer, e.g. &#8220;Multiply&#8221; or &#8220;Overlay&#8221;. Does your character wear armor? Try adding a metal texture with scratches and wear-and-tear.</p>
<p><strong>Warping and liquify: </strong>Sometimes you need to push things around, like if you import a 2D texture that needs to be warped according to the grid lines of your UV snapshot. You can use <em>Edit &#8211; &gt; Transform -&gt; Warp </em>or <em>Filter -&gt; Liquify.</em></p>
<p><strong>Pressure-sensitive tablet: </strong>This is a no-brainer. Texture-painting solely with a mouse is possible but extremely limiting. A pressure-sensitive tablet is a good investment (if you do not already have one) and will definitely make your day easier as an artist.</p>
<p><strong>Pressure-sensitive brushes:</strong>  If you have a tablet, try experimenting with the brush settings under &#8220;Brushes&#8221;. Especially &#8220;Shape dynamics&#8221; (size) and &#8220;Other dynamics&#8221; (opacity).</p>
<p><strong>Basic brushes: </strong>I tend to use a basic hard round brush, a soft one, and combinations of these with sensitivity for either size or opacity. Try making other brushes by painting a black-and-white pattern on a square canvas and hit <em>Edit -&gt; Define Brush Preset </em>(or simply download free brushes on the net).</p>
<p>With those few tricks freshly memorized, it&#8217;s time to paint!</p>
<ul>
<li>Start with a color filling the entire background (left image).</li>
<li>Import reference from 3D-painting if available.</li>
<li>Using your UV snapshot, and popping in and out of Maya to check the effects of your actions, start painting in the basic colors with a hard round brush for each mesh piece or body part (middle image). You can also use your AO layer for reference.</li>
<li>Once you have painted in all your desired colors, try enabling your AO layer to see how it looks (right image).</li>
<li>Want more detail? Experiment with more advanced brush settings or add external textures with blending.</li>
</ul>
<p><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_painting/" rel="attachment wp-att-1117"><img class="aligncenter" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_painting-1024x333.png" alt="" width="655" height="213" /></a></p>
<p>When satisfied, save out your work. I like saving as .PNG (which also stores transparency), though you may find a better choice depending on the requirements of your project (consult your art director or lead programmer if you have one). If you have an established pipeline, it will most likely do batch conversions of textures and assets at some point, so keep your original textures in high quality is always a good thing. Save the file in the same resolution as your PSD. Name it something like <em>yourcharacter_diffuse.</em></p>
<h3>Specularity and other maps</h3>
<p>If you want additional control over other properties than just color, you can create other maps as well. For example, you may want Sir Nigel&#8217;s top hat to be extra shiny. Shininess, or rather specularity, is determined by a specular map. Create a new layer in your Photoshop texture-file and paint with black-and-white, black representing matte, gray semi-glossy and white very glossy. Paint as in the picture below:</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_spec/" rel="attachment wp-att-1158"><img class="aligncenter size-full wp-image-1158" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_spec.png" alt="" width="177" height="177" /></a></p>
<p style="text-align: left;">You can use the same technique for controlling other surface-properties such as bumps (e.g. for hairs and fur) and transparency (the glass of Nigel&#8217;s monocle). A much-used map in video games is the normal map. Normal maps are color images providing rendering information for how light should be reflected on the surface of the mesh. They are often used for giving the illusion of indentations and protrusions on flat surfaces, such as muscles, bones and wrinkled clothing and so on. Normal maps can be created from high-polygon versions of your mesh.</p>
<h3>Wrapping it up</h3>
<p>OK, let&#8217;s conclude this part of the tutorial by adding our diffuse and specular maps in Maya:</p>
<ul>
<li>Create a Blinn material and assign it to your mesh.</li>
<li>Open the Attribute Editor (CTRL+A) to edit the material properties.</li>
<li>Enter your diffuse map in <em>Common Material Properties -&gt; Color.</em></li>
<li>Enter your specular map in <em>Specular Shading -&gt; Specular Color.</em></li>
</ul>
<p>If you want to render an image of the result, do the following:</p>
<ul>
<li>Add a primitive plane to your scene. Stretch it out so that it acts as the ground. Select two sides of the plane (the ones visible in your perspective camera), extrude those edges and &#8220;lift&#8221; them to create walls. When done, hit &#8220;2&#8243; on your keyboard to smooth it. Apply a white Lambert-material to it.</li>
<li>Then add an ambient light to your scene and position it.</li>
<li>Set your renderer to mental ray.</li>
<li>Position your perspective camera, open the IPR renderer and select a small portion of the scene for live preview-rendering.</li>
<li>Now, play with the settings of your mesh&#8217;s material and the lights/background until you are satisfied with the result in the IPR renderer. Also try experimenting with the render settings such as quality.</li>
<li>When happy, render the current frame with mental ray.</li>
</ul>
<p style="text-align: center;"><span><a href="http://www.displayhack.org/2011/maya101-2/maya101_p2_render-4/" rel="attachment wp-att-1166"><img class="aligncenter size-full wp-image-1166" src="http://www.displayhack.org/wp-content/uploads/maya101_p2_render3-e1314523439585.png" alt="" width="310" height="307" /></a></span></p>
<p style="text-align: left;"><span>That concludes this tutorial part. We now have a 3D mesh with maps for diffuse and specularity. I hope you have enjoyed this tutorial, and <a href="http://www.displayhack.org/forums/topic/modelling-in-maya-101-part-2/">please feel free to ask questions or add your own work in the forum!</a></span></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=751&amp;md5=353bc03e3557548f7dc2f89fe3f2d71d" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/PNpgJN7FAiQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/maya101-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/maya101-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=maya101-2</feedburner:origLink></item>
		<item>
		<title>Making-of: “The Lacquerer”</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/KUeXDpULQhU/</link>
		<comments>http://www.displayhack.org/2011/the-lacquerer/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 08:47:40 +0000</pubDate>
		<dc:creator>Ollie "Cosmic" Borgardts</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Making-of]]></category>
		<category><![CDATA[after effects]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[behind the scenes]]></category>
		<category><![CDATA[blender]]></category>
		<category><![CDATA[maya]]></category>
		<category><![CDATA[messiah]]></category>
		<category><![CDATA[modelling]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[zbrush]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=892</guid>
		<description><![CDATA[

Hi, I'm Ollie "cosmic" Borgardts, and I am the creator of the animated short "The Lacquerer". I'm going to do my best to make this an interesting and entertaining read, but I should probably say up front that I will go into detail on how the movie was made. I'll also touch upon the ...]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/28078893?title=0&amp;byline=0&amp;portrait=0&amp;color=f20505" width="621" height="349" frameborder="0"></iframe></p>
<p>Hi, I&#8217;m Ollie &#8220;cosmic&#8221; Borgardts, and I am the creator of the animated short <strong>&#8220;The Lacquerer&#8221;</strong>. I&#8217;m going to do my best to make this an interesting and entertaining read, but I should probably say up front that I <strong>will</strong> go into detail on how the movie was made. I&#8217;ll also touch upon the creative process and my personal experiences from making this production. At the bottom of this post I have attached a 30-minute walkthrough video in which I explain some of the techniques I used.</p>
<h3>Behind &#8220;The Lacquerer&#8221;</h3>
<p>The whole production took about 2 months (full time) to complete, and with such a long production time I feel I have plenty of tips about the production process and the ideas and techniques that went into the piece. The short was released at the <a href="http://revision-party.net/">Revision Demoscene Party 2011</a> where it won the Animation Competition.</p>
<p>The whole project started two months before the competition was to be held, when a good friend of mine, Pro from the demo group Nuance, told me about a promotional campaign for a 3D package named <a href="http://www.projectmessiah.com/x6/index.html">Messiah Studio</a> at a very good price. I have been a faithful Maya-user for many years, but when I checked out the package, some of the features it offered were very interesting. Even though I had never used it before, I promptly ordered a license in the belief that I could learn what I needed to know in good time before the competition deadline got too close.</p>
<blockquote><p>One trick I learned was to watch tutorials at double or triple speed to save some time</p></blockquote>
<p>I really wanted to finish a cool production for Revision, so with hindsight being 20-20, I probably picked a bad time to start learning a new 3D package. I proceeded to spend quite some time just watching various tutorials online, to get to know the application and the differences from Maya. One trick I learned was to watch tutorials at double or triple speed to save some time (no joke, it&#8217;s what I did and it was very effective).</p>
<p>Just to touch on the fact that I decided to switch 3D packages. I do simply love Maya. I use an older version (6) which I bought several years ago and I&#8217;ve been using it so long that I know the program in and out and can therefore work quite efficiently in it. However, I do have some issues with it.</p>
<p><img class="size-medium wp-image-910 alignleft" src="http://www.displayhack.org/wp-content/uploads/Camera-422x250.jpg" alt="" width="405" height="240" /></p>
<p>When creating digital characters I would begin in ZBrush and then bring it into Maya for rigging. To bind the bones to the geometry Maya requires you to go through a process called &#8220;weight painting&#8221;. This tells the skeleton how much influence each single bone has on the bound geometry. There are a few scripts that help you automate then I need to bind the bones to the geometry and do a process called weight painting. This tells the inserted digital skeleton how much influence every single bone has upon the bound geometry. There are scripts to partly automate the process, but to be honest: most of them suck, and doing it manually sucks even more.</p>
<p>There are most likely newer versions of Maya that has new features or techniques for rigging and skinning, but for me, taking the step over to Messiah really helped me out. One example: in Maya, if I want to change something after the bone structure has been set up and bound to the mesh, I would have to unbind all of it and repeat the process on the new or changed mesh.</p>
<p>For an artist, this workflow is killing productivity. I want to be free from the very beginnng, the planning stage, the modeling, texturing, animation and right up to the final export or the encoding process. I want to be able to make changes at any point in that toolchain. Period.</p>
<p>Another example: changing the character from a humanoid biped to, say, a 3-legged beast with 10 arms, I&#8217;d have to repeat the whole process. Again, this doesn&#8217;t work for me. This is one of the areas where Messiah shines. It has a very clever way of separating the binding/rigging-stage from the animation. If I wanted to add more bones, I&#8217;m able to do so, and the animation and other parts remain untouched. Awesome.</p>
<h3>Thoughts on creativity (and art in general)</h3>
<p>I was now in a place where I knew how to use Messiah &#8212; which is exactly the time that the creativity black hole hit me. I&#8217;d like to share some thoughts about creativity in general and about the approach I use when realizing my ideas.</p>
<p>My tools of choice are Maya (or now: Messiah), After Effects, Photoshop and ZBrush. Not necessarily in that order.</p>
<p>I believe that there are really no &#8220;new things&#8221;. Pretty much everything has been done before in some way. Even so I look at other artists and what they doing and I&#8217;m definitely learning something new every single day, and that&#8217;s a good thing. However, if it&#8217;s one thing I know it&#8217;s that creativity can&#8217;t be forced when you are on a deadline.</p>
<p>I want to surprise the people at the event with my production, but how could I surprise them if I can&#8217;t even surprise myself? For each project I start, my personal goal is always to surprise myself in some way &#8212; to create something I&#8217;d never thought of before it&#8217;s actually finished.</p>
<p>So how can this be achieved? Well, I know what I&#8217;m able to. I know what I&#8217;m too unskilled or too lazy for. I know my tools. I know my skills and my preference when it comes to art. I know these things inside and out, so how do I &#8220;trick&#8221; myself? Well, one approach is to combine existing things. Take, for example, three existing things and combine them in some random fashion. It doesn&#8217;t matter which way you do it. The point is to not be logical and simply negate the facts.</p>
<p>Just to give you a little example of the process that works well for me:</p>
<p>Look out your window at the scenery outside. Then go: &#8220;Why do trees have their roots planted in the groud? What if it was upside down?&#8221; <em>Argument one: defined.</em></p>
<p>Continue with the simple assertion: &#8220;What would happen if the tree was planted upside down?&#8221; Well, for one, it wouldn&#8217;t be able to access any water. So the consequence of this could be that the roots would need to stretch to the clouds to access water. <em>Argument two: defined.</em></p>
<p>But what with the birds that usually sit on the soft branches? They don&#8217;t want to sit on the ugly, muddy roots. No, they want to sit on the branches and leaves as before. Therefore the result could be that they hang themselves upside down instead, reaching for the branches. <em>Argument three: defined.</em></p>
<p>..and boom &#8212; there&#8217;s your scene. The rest is just a matter of a technical completion, however you choose to proceed.</p>
<p><img class="size-medium wp-image-826 alignright" src="http://www.displayhack.org/wp-content/uploads/ThoughtsBoutArt1-333x250.jpg" alt="" width="433" height="325" /></p>
<p>The image to the right isn&#8217;t exceptional, but I hope you get the idea how everything in an artistic world could be created in this way. Just let the things happen. You don&#8217;t want to control everything or be too logical here. That simply doesn&#8217;t work &#8212; or, to be more precise &#8212; it simply doesn&#8217;t work <em>for me</em>. I know a thing or two about the technical stuff, but in the creation process of something artistic, taking a logical approach is just disturbing the art.</p>
<p>However, when the creative process is completed, you can come back and go on working on it in a professional, logical and disciplined way.</p>
<h3>When perfectionism and ego gets in the way</h3>
<p>At an early stage of making &#8220;The Lacquerer&#8221; I just wanted to use ZBrush, model something and then animate it. I asked a friend of mine, Marc Ewald (a musician from the Netherlands), if he&#8217;d like to do a soundscape for it (just like he did for &#8220;<a title="" href="http://capped.tv/playeralt.php?vid=nuance-julie">Julie</a>&#8221; my last short movie experiment for Breakpoint 2009). I believe he&#8217;s a genius in what he&#8217;s doing and so the brief I gave him went something like this:</p>
<p><em>Please think of a concept for a short film (but don&#8217;t tell me what it is) and then create a soundscape for it. No identifiable sounds like bird chirps, car horns and such. Just make something abstract that will fit with loosely defined terms of contrast, such as &#8220;fast&#8221;, &#8220;slow&#8221;, &#8220;large&#8221;, &#8220;small&#8221;, &#8220;oppresive&#8221;, &#8220;liberating&#8221;. Again: don&#8217;t tell me the meaning of it. I plan to let the story unfold itself while I&#8217;m making it.</em></p>
<p>The reason for this was of course to have no preference or preconceived notions when starting up. I could listen to the sounds as a small child would and just let the imagination kick in. What would I think of those sounds &#8212; what would they look like? Then I could concentrate on creating something visual around the sound completely disconnected from the visuals.</p>
<p>What I got from Marc was very good. Bombastic, epic, almost score-like in nature. I could picture it in a game such as &#8220;Metal Gear Solid&#8221;. It was absolutely fantastic and I was speechless. My problems started when I was trying to visualize them. Suddenly my creativity was .. gone.</p>
<p>I had vivid pictures in my mind, such as huge boss-fights in epic PlayStation 3-games. The sound was great, but I kept thinking: &#8220;How on earth am I going to be able to match this, visually? How can I live up to the expectations the sound is setting the scene for?&#8221;</p>
<p>I thought about all those things for a couple of days, and then, as it does, a happy accident occurred.</p>
<p>I stumbled upon some audio samples I had laying around on my harddrive. They sounded interesting so I chopped them up randomly to a 3 minutes collage. I also, for some reason, started modelling an old guy in ZBrush.</p>
<p>At this point I was slightly tired of the whole thing, but stuck to it anyway. Working on something was better than thinking about it. I believed that a solution would present itself, as it usually does.</p>
<p>I threw some bones onto the pretty sloppily created mesh and started animating it in a random way. No plot &#8212; just trying to forget how I would go about handling the miserable situation I was in. I had no idea on what to create, and I felt really bad for Marc who had created a great piece that simply wasn&#8217;t what I needed at the moment. I really wanted to use it, but it was dawning on me that it wasn&#8217;t what I was looking for this time.</p>
<p>I rendered out some seconds of crap and brought it into After Effects where I started playing with color correction and other generic things. I just wanted to keep working, waiting for <strong>the</strong> solution &#8212; <strong>the</strong> idea &#8212; <strong>the</strong> special technique.</p>
<p>This is when I more or less randomly started playing with a feature in After Effects called..</p>
<h3>Time Remapping</h3>
<p>Time Remapping squeezes and stretches your video footage by changing the timing and playback rate. You can slow down things or speed them up, and it does the same with the sound &#8212; just like a record on a turntable. It&#8217;s a very basic feature, and pretty much the first thing you learn when you start using it. However, I had I never thought about using this in a creative way. It was too simple, far away from the &#8220;epic effect&#8221; that you see in the movies. It&#8217;s totally overused, boring and just too simple.</p>
<p>In fact it&#8217;s so simple that I thought everyone using After Effects is using it. This is where ego kicked in.. &#8220;I wouldn&#8217;t use that &#8212; not me &#8212; the best digital artist in the universe &#8212; the one that only uses super-complex techniques &#8212; not even people at ILM do what I do..&#8221;</p>
<p><strong>What utter bullshit!</strong> Ego struck again! The little bastard in my head took over and was controlling me in a very destructive way that lead to total stagnation &#8212; and I didn&#8217;t even realize it at the time. Instead of having fun with the new software, the digital tools and playing around with them to create something cool in a fun way, my ego &#8212; the perfectionism and logical approach &#8212; ruined everything.</p>
<p>This cheap and simple trick which I just played with by accident ended up as the concept for the shole short. All the content I was to create in the coming four weeks would be held together by this very basic tool. I decided to write it down so as not to loose it: <em>&#8220;Create a very detailed creature, animate it in some way, sync it all with Time Remapping afterwards!&#8221;</em></p>
<p>This cheap, simple trick, found &#8220;by accident&#8221; was the concept for the whole movie. This would hold everything together. So I wrote it down that this won&#8217;t be lost again: &#8220;<em>I&#8217;m going to create a creature with the best skills I have at this time &#8211; I&#8217;m going to bring it into messiah and animate it in some way, but in perfect sync to the audio to &#8220;destroy&#8221; it afterwards with simple time remapping</em>&#8220;.</p>
<p>Then another problem presented itself: I still wanted Marc to do the soundscape. He has studied composition after all, and he&#8217;s by far my musician of choice to work with. But he needed some clips of the concept to create the audio, and that was a problem because none really existed at this point. My solution ended up being that I would animate the short with the glitchy audio I had already created, and he would create a new, better sound for it. Remixing it, in a way, but keeping the same major sync points.</p>
<p>Unfortunately, that never happened.</p>
<p>I was working non-stop with animating right up until the last day before Revision was about to begin, and therefore I couldn&#8217;t expect Marc to be able to create everything needed in only 12 hours. I&#8217;m quite sad about that, but I didn&#8217;t want to put him in the same position as I was in earlier &#8212; what if he wasn&#8217;t inspired with what I had created? Lesson learned: the next time I&#8217;m going to involve him at an earlier stage, promise.</p>
<h3>Giving life to the creature (blendshape creation with 3D layers)</h3>
<p>I spent some time modelling the figure, texturing it and creating the blendshapes for it. All of this was done inside of ZBrush. I love ZBrush, it has never let me down. In other applications you can very easily end up stuck in a one-way street somewhere down the pipeline or the production process, but with ZBrush I have never had this happen. At any point there is a way to backtrack and get back to what you need to change.</p>
<p style="text-align: left;"><img class="size-medium wp-image-863 aligncenter" src="http://www.displayhack.org/wp-content/uploads/Layers-451x250.jpg" alt="" width="496" height="275" /></p>
<p>So what are blendshapes? You can think of them as layers in Photoshop, except in 3D space. You create different &#8220;versions&#8221; of your model on layers and with a slider you can switch between these and create stuff like facial expressions this way.</p>
<p>These are then exported with the original mesh and connected inside of the 3D application. Every major-vendor 3D package has those &#8211; Blender, mMx, Maya etc, but their lingo might differ (like &#8220;morph targets&#8221;). These imported blendshapes are then invisibly connected to your original model and can seamlessly be blended into each other. This again can then be keyframed and animated.</p>
<h3>Principles of complex effects (or: &#8220;Hollywood has time and money&#8221;)</h3>
<p>One look I wanted to create for the project the figure was one of having the character look like he was coated with something like clay or mud. If you&#8217;ve seen any of the X-men movies then you probably know the character &#8220;Mystique&#8221; (if not: <a href="http://www.youtube.com/watch?v=upL3Y2V_5gY">this is what that looks like</a>). Her skin morphs in a pretty crazy way. It&#8217;s not just blended though, it looks like there&#8217;s more going on under the surface, like tiny, greebly, flaky stuff. It looks really hard, but actually it is &#8212; once again &#8212; very simple.</p>
<p>I couldn&#8217;t find the technique described in any tutorial, book or in the 3D forums online, so I couldn&#8217;t get it exactly right. My effect isn&#8217;t as elaborate or worked-through like the one I mentioned, but I think it worked out well and I&#8217;m going to show you the basic principles behind it.</p>
<p>The basic idea is to create two morph targets &#8212; one untouched (a clean slate, if you will) and one for the tranformed shape (a mask or one with scales or whatever you like). Step one is taking these two models and blend them using influence modifier objects like a sphere or a cube or any shape you can think of. That gets you started, and you have great control over the look of the animation, but the desired &#8220;greeble-look&#8221; isn&#8217;t there yet. So step two is to add complexity where the blending areas of the structure are switching from one shape to another. For this I created a third map that distorts the model in a very overdone way. Very random and crazy.</p>
<p>At that blending point this third map is basically used to &#8220;destroy&#8221; the geometry in a small rim. This gave me that &#8220;wrapping around&#8221; effect you see when the figure is coated. I could have used an animated map as well to enhance this effect even more (and I think this is how they create the skin effect on &#8220;Mystique&#8221; as mentioned above), but I was satisifed with the way it looked.</p>
<p>Another, simpler, technique would have been to render out two versions of the animation and then simply blend them in post-production. However, this won&#8217;t give you correct shadows and the compositing job would have been at least triple the work in the end. Real geometry is nearly always best, if you can get it right.</p>
<h3>The devil is in the Multi Displacement Map layering (aka &#8220;details&#8221;)</h3>
<p>As you might know, the models you can get from ZBrush can have a very high poly-count. With an average computer with 4 GB of RAM you can easily make models containing up to 100 million polygons or more.</p>
<p style="text-align: center;"><img class="size-medium wp-image-872 aligncenter" src="http://www.displayhack.org/wp-content/uploads/Displacement-333x250.jpg" alt="" width="433" height="325" /></p>
<p>ZBrush can handle this because internally it&#8217;s not using polygons, but something they call <em>pixols</em> &#8212; more commonly known as voxels. These are pixels with depth information. It&#8217;s a clever fake so that you can work comfortably inside of ZBrush without lag, but once you actually export the model, it is converted into real polygons. The most common approach to maintain a high detail level is to create a displacement map or normal map and place this onto a lower poly-count version of the model.</p>
<p>Displacement maps are nothing more than grayscale images (colored ones for normal maps) that create the illusion of having the same high detailed level. A little clarification: with normal maps this is the truth, but with displacement maps the high poly count is acually created during the rendering process.</p>
<p>I took these mapps and added them to the blending process in Messiah with the same influence blend modifieres to bring in details in the model and color-space as well. However, a single displacement map didn&#8217;t yield the result I was looking for so I had to research the technique of using so-called &#8220;Multi displacement maps&#8221;.</p>
<p>Imagine a base model, like a sphere with 100 polygons. You can create a displacement map that deforms this sphere in a good shape, like the basic shape of a human head. With only one displacement map you can just pull &#8220;outwards and inwards&#8221; to create indentations. The side planes of each newly created &#8220;extraction&#8221; can then not be affected anymore by the same displacement map and this is a shame.</p>
<p>If you extract a normal with a displacement map that results in some sort of &#8220;cubic&#8221; form. Then you have no information left in the map to extract the faces again in direct way, because the &#8220;detailing side parts&#8221; are simply just being created during the rendering process. With this in mind, a single displacement map wasn&#8217;t really that useful. You need another map that provides that information, and the good thing is that you can stack tons of maps onto each other and get really deep details out of it. At the time I started this project I didn&#8217;t know how to do this, but as it turns out, it was surprisingly simple (as in: just the click of a button). You can watch the process in the making-of video at the bottom of this post.</p>
<h3>Compositing is everything (or: &#8220;How to make crap look good&#8221;)</h3>
<p>With the model, morph targets and textures done, it was time to getting it to look good. While I&#8217;m proficient in creating 3D models, it&#8217;d be a lie to say that this is my favourite thing in the process. I see it more as a necessary evil, because creating things in virtual 3D space eventually brings you to the point where it starts to suck. Or to put it differently: you can never expect to finish your projects in your 3D programme. You need post-processing. Even if your lighting setup is perfect, you animation looks good and the models are perfect &#8212; the true power comes when you step out of 3D space and enter post-processing land.</p>
<p>When I started toying with 3D modelling and animation almost 15 years ago I thought that the way the professionals worked was to set up a scene, model, animate it, set up the lights and click the render-button. In reality, no movie is made in this way, because it&#8217;s simply neither practical nor yield good enough results. Think about it like layers: what if the base rendering takes 15 hours to finish? What are you going to do if the shadows are too dark or the colors are slighty off? You can&#8217;t just render it again &#8212; a very bad workflow.</p>
<p>The correct (and only) way to do it is to composit different layers on top of another, with the base rendering being the lowest lever in your chain. Everything is done in layers, and when combining them (following some simple principles and a few standard rules) is what nails the look and feel of a movie. Once you know these rules you are also capable of breaking them, which is what I usually do. In all my pieces they were at some point at a stage that I just played around in Photoshop to try the find a look or a feel, but the basic workflow and the principles remained the same.</p>
<p>Warning &#8212; soapbox moment! It&#8217;s really about the basics. Turning on a plugin isn&#8217;t just lame, it&#8217;s counter-productive, because it means you&#8217;ll never know what&#8217;s truly going on under the hood, and therefore unable to control it well. Some plugins can make your life easier when you are in a hurry, but is no substitute for having a really good set of basic skills. Do your homework. Buy books on anatomy and lighting. Knowing these basic principles will make your work better.</p>
<p>Oh, and a top-tip: always render to still image sequences. If you suffer a crash or a powerloss during rendering to a movie-file, all is lost, while if you worked on a still image sequence, you can just set your renderer to continue where it left off.</p>
<h3>Shading the character</h3>
<p>The best looking renders, in my opinion, are the ones I get directly out of ZBrush. ZBrush is fast and uses lighting baked into so-called MatCap Materials. The only problem with ZBrush is that it has no real 3D space. Again, these are only pixels with depth information and so you can&#8217;t &#8220;go around them&#8221; (or I should rather say &#8220;walk inside of a model&#8221;), because you can&#8217;t rotate 2D. In ZBrush it&#8217;s actually 2.5D information you&#8217;re dealing with</p>
<p>To make skin look real you need a feature called subsurface scattering. Think of it as holding your hand in front of a strong light-source at night, where you can see the light through our fingers. This is due to the scattering of light inside of your skin. I really wanted this look in the movie, so to enhance it I set up a simple shading network inside of Messiah to get a rim shader.</p>
<p>For stills I get everything out of the programme: depth Pass, diffuse pass, SSS, specularity and so on. The trick lies in using these elements to make it look real in the compositing stage in Photoshop (if you&#8217;re working on a still image) or After effects (for movies).</p>
<p>The key things are: color, perspective, depth and hue.</p>
<p><img class="size-large wp-image-886 alignright" src="http://www.displayhack.org/wp-content/uploads/Compositing-1024x597.jpg" alt="" width="430" height="251" /></p>
<p>I&#8217;m going to show you a simple way of getting a simple, really ugly and random scene to look realistic in some way by just following a few simple steps. Mind you, this technique is for still images only. You can see the end result in this image to the right, and for the how-to, watch the making-of video at the bottom of this post where I go through each step of the creation of this image.</p>
<h3>Getting the look down to a sensible render time</h3>
<p>I wanted to use the so-called MatCap Materials for the shading of the skin. Matcaps handle the way of shading in a very clever and fast way, and they look really cool, so I wanted to use these inside of Messiah. In Maya or Blender the setup for such a shading network is pretty easy, but not in version 6 of Maya. In messiah I had no clue on how do it, but luckily there is a nice and friendly Messiah-community from which I got help an tips on this. One of them even set up a full shading network for me, but sadly had no time to implement it due to the looming deadline. In my next production I&#8217;m going to use these techniques.</p>
<p>However, I still want to show you how the MatCaps can be used inside of Blender. The workflow can be most likely be applied to every other major 3D package.</p>
<p>In ZBrush, just render out a sphere with the desired material applied to it. Make sure the document width and height are at the same settings and that the sphere is perfectly placed in the center. Oh, and turn of perspective in ZBrush &#8212; using the orthogonal view will give you the same result. Export that texture and map it using to the color channel using the normals. Make sure that your shader is turned to shadeless because the light is already baked into the the texture, and the painted color information from the actual model is simply added on top of that. This way, you&#8217;ll get the exact same look as if you were still in ZBrush. That&#8217;s it.</p>
<p><img class="size-medium wp-image-897 alignleft" src="http://www.displayhack.org/wp-content/uploads/Shading-336x250.jpg" alt="" width="363" height="270" /></p>
<p>With everything rendered out, it was time to have fun! I used Time Remapping here and there in After Effects and was fascinated by the sense of randomness and oppressive mood that it caused. The character was absolutely animated to the sound, but with the added effect of having the sound also stretched and squeezed where I used Time Remapping. I really liked how everything was coming together at this point.</p>
<p>One thing I haven&#8217;t touched upon is the glass panel in the movie. It was entirely done in post. Just a simple 2D tracking of the hands touching the glass and then a few dirt textures on a null object.</p>
<p>In terms of the story, my first idea was to the character break the glass when he hits it, but I found it more creepy and scary if he was still stuck behind the wall of glass.</p>
<h3>&#8220;Making-of&#8221; and explore the scene files</h3>
<p>If you&#8217;re interested in the scene files for this movie you can download them (<a href="http://www.higher-lyrics.de/project.7z">project files</a> &amp; <a href="http://www.higher-lyrics.de/head.7z">head</a>), play with them and explore how they were done. I have also created a 30-minutes &#8220;Making-of&#8221; video which touches on many of the techniques described above.</p>
<p>I want to say thank you for your time and your interest in how all this was done. Of course not every single aspect and every problem that occurred during the creation process could be described here. Even if I&#8217;d tried to cover them here to warn you before embarking on your own projects, other problems will still occur. The devil is in the details.</p>
<p>It was really, really hard work to create this movie. Pain and fun and I earned a lot by going through the process. If they happen to read this, I would like to offer an apology to my friends and family who were really forgiving during my mood-swings. :) Also, thanks to the people sharing their comments and critique about the movie so far &#8212; I hope you will take time to watch it and comment below as well.</p>
<p>So, stay tuned, keep creating you own productions, don&#8217;t let discipline and perfectionism ruin your creativity &#8212; just don&#8217;t take life too serious and have fun (yes, I know &#8212; this applies to me as well :)</p>
<p><iframe src="http://player.vimeo.com/video/28123820?title=0&amp;byline=0&amp;portrait=0&amp;color=f20505" width="621" height="349" frameborder="0"></iframe></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=892&amp;md5=cde45ad54e0bba3c60e386b9f29a2c66" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/KUeXDpULQhU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/the-lacquerer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/the-lacquerer/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-lacquerer</feedburner:origLink></item>
		<item>
		<title>Node Code: Quartz Composer Overview (Part 1 Of Infinity)</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/QOP3MaFkmnw/</link>
		<comments>http://www.displayhack.org/2011/node_code_series/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 07:27:29 +0000</pubDate>
		<dc:creator>George Toledo</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[execution graph]]></category>
		<category><![CDATA[qc]]></category>
		<category><![CDATA[quartz composer]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=580</guid>
		<description><![CDATA[
This is going to be an ongoing column, concerned mostly with execution graph technology and Quartz Composer. I originally was going to write a piece about Quartz Composer, and attempt to cover basics and some uber-cool projects done with it. The reality is that the subject is way too broad to cover in one ...]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="Mandelbulb QC" src="http://www.displayhack.org/wp-content/uploads/mandelbulb_qc_top.jpg" alt="" width="616" height="174" /><br />
This is going to be an ongoing column, concerned mostly with execution graph technology and Quartz Composer. I originally was going to write a piece about Quartz Composer, and attempt to cover basics and some uber-cool projects done with it. The reality is that the subject is way too broad to cover in one article.</p>
<h3>Getting started</h3>
<p>Since I&#8217;ve become involved with Quartz Composer (also known as &#8220;QC&#8221;), I&#8217;ve read countless posts to Apple&#8217;s Quartz Composer Developer list or <a title="Kineme" href="http://kineme.net">Kineme</a> where users complain about a lack of documentation. I don&#8217;t think that criticism is entirely valid; I think it&#8217;s a matter of history, and this article is going to go into that a bit. What follows will be a bit of broad overview of some issues surrounding Quartz Composer, while future articles will be more in depth and certainly have a great amount of info that one can use in many domains, not just Quartz Composer, though there will be a focus on implementing in QC.</p>
<p>Back to the common complaint of lack of documentation; a cursory browsing of the internet will reveal countless pages that attempt to explain Quartz Composer, they just don&#8217;t explain the problem the user wants to solve. Users often disregard Apple&#8217;s documentation as a starting point as well. I suggest <a title="Apple Quartz Composer Programming Guide" href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/QuartzComposer/qc_intro/qc_intro.html#//apple_ref/doc/uid/TP40001357">Apple Quartz Composer Programming Guide</a> as a very good piece of reference material.</p>
<p>Apple has done a great deal of documenting of Quartz Composer, provided tons of example projects that show how to work with Quartz Composer graphs (qtz files), how to write plugins for Quartz Composer, or integrate it into applications that use the technology. Doing a search through Apple&#8217;s Developer code will reveal numerous examples and articles, all of which I would recommend that anyone interested in Quartz Composer examine. I think these are the absolute best examples and documentation of Quartz Composer in existence.</p>
<h3>The documentation workaround</h3>
<p>That said, there is a very major reason why people tend to immediately ignore Apple&#8217;s documentation, and it&#8217;s somewhat valid.</p>
<p>With Apple&#8217;s standard API, one can indeed expand the modules that Quartz Composer loads into it&#8217;s environment by writing plugins that one can construct graphs with, but it also places numerous embargoes on that QCPlugin API. There is a large subculture &#8211; or perhaps the dominant culture &#8211; of QC users that utilize what has become known as &#8220;the SkankySDK&#8221; to circumvent this. For example, Apple may prevent plugins from loading inside of certain environments like the Web Browser, or from utilizing built in QC data types like &#8220;QCMesh&#8221; (because of proprietary reasons or simply a lack of updating the spec. Speculation is probably unhealthy!)</p>
<p>Before Apple had actually published a plugin API, users were eager to extend Quartz Composer&#8217;s functionality. QC was based on Pixelshox, which was also an extendible technology, and number of users had noted that Apple had also designed Quartz Composer to load &#8220;GFPlugins&#8221;. By backwards engineering this API, this soon became a way for users to extend Quartz Composer&#8217;s functionality. By the time that Apple had actually introduced a plugin API, several developers were already using the &#8220;skankySDK&#8221;, and numerous plugins that conformed to this standard &#8220;non-standard&#8221; had been released. Interestingly, Apple continues to create GFPlugins for use in their own projects, choosing not to eat their own dog food. <a href="http://www.youtube.com/watch?v=WhXOPDqVYBE">The infamous tape</a> where Apple calls the reverse engineered SDK the &#8220;skanky&#8221; SDK while introducing their hobbled SDK is entertaining enough though.</p>
<p>What was most problematic is that through use of GFPlugin/skankySDK one could create new data types inside of Quartz Composer, and leverage control over the entire system. QCPlugin uses a wrapper that precludes one not only creating new data types, but also creating certain types of macros, or even utilizing certain built in data types.</p>
<p>While it is far from useless, and one can create a great deal of things in that box, the fact that QCPlugin is limited, but accepted by Apple, has a significant impact on Quartz Composer development and culture. If one wishes to create new modules that are allowed in apps to be sold on Apple&#8217;s app store, one must write plugins in that box. If you wish to write modules in a way that leverages complete control, you use the skankySDK, fully knowing that this isn&#8217;t viewed as an awesome thing by Apple, and also, that they do not support.</p>
<h3>With a little help from your friends</h3>
<p>Over the years, <a title="Kineme.net" href="http://kineme.net/">Kineme</a> codified the non-standard plugin API/skankySDK into an actual framework, which is available at their site. <a title="Kineme's forum" href="http://kineme.net/forum">Kineme&#8217;s forum</a> is also the largest community of Quartz Composer users, and a great place to get feedback and help, as well as an excellent source of add on modules. Another very noteworthy developer in the QC community is Anton Marini, a.ka. Vade. His v002 plugins are considered to be some of the most useful plugins available for Quartz Composer, and he also shows how far boundaries can be pushed even when using Apple&#8217;s standard QCPlugin API (and he also has a forum for support).</p>
<p>It may seem quirky to lay all of that out on the front end, before even getting too far into &#8220;what Quartz Composer is&#8221;, but I never said I wasn&#8217;t quirky. I think it&#8217;s important to understand this when delving into Quartz Composer, and good to understand it before getting deep into interacting and programming with the system.</p>
<h3>The inner workings of QC</h3>
<p>Quartz Composer is multifaceted. It presents itself in the form of a framework for OS X, as a technology, and as an application to leverage the technology. A good way to think of Quartz Composer is that one is creating a file, and that by linking together modules (patches) with cables (noodles), one can send information from one module to another. Anyone that is familiar with node based editing systems may also think of these as nodes, and of Quartz Composer as a node graph, and that&#8217;s an accurate description. Others may think of this as a decision graph, or an execution graph. There are strong parallels with non-programmer paradigms, especially signal flow. Musos that have chained together multiple effects boxes, or modular synths have a good running start to understanding the method of interaction with QC. Users typically work with the Quartz Composer.app, which is included with Apple&#8217;s Developer Tools, to create and manipulate Quartz Composer graphs.</p>
<p>In Quartz Composer, a method is used that is called &#8220;lazy evaluation&#8221;. QC graphs tend to lay out from right to left on the Quartz Composer editor application. When one connects the output of a QC Video Patch, to the image input of a QC Sphere, execution happens thusly: The QC Sphere is a &#8220;Consumer&#8221; patch. First, a check happens to see if it is enabled. Then, all input port values are surveyed.</p>
<p>If there is a value at the port, it&#8217;s used. If there is a connection to another patch upstream, like the Video Patch, that patch then executes. If the Video Patch output was connected to nothing, it would never execute at all. If there was a switcher in between (known as a multiplexer in QC parlance), and connections existed, but the Video Patch was not currently chosen, the Video patch would still not execute. If that Video Patch has an input port, connected to another patch&#8217;s output, then it will trigger the next patch in the line to execute. This is likely an important distinction to make to people familiar with graph environments that use a Push model (like Max or VVVV).</p>
<p>The fact that one can program plugins, whether skanky or standard API, that there is a defined evaluation mechanism, that one can incorporate any of Apple&#8217;s frameworks fairly easily, use past work modularly, or write GLSL shaders, OpenCL kernels, JavaScript programs in the Quartz Composer editor while live compiling and seeing the output results render in the QC Viewer while working makes QC a tool for some projects that is indispensable.</p>
<p>I&#8217;m excited to delve into that more. In coming installments, we will learn about creating graphs, prototyping shaders and CL kernels, extending functionality with the standard and skanky SDK&#8217;s, integrating Quartz Composer into standalone apps, as well as broader issues in coding and how they interplay with this technology.</p>
<p>&nbsp;</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=580&amp;md5=19461679e7a2f46e0f77c9c4ca32e712" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/QOP3MaFkmnw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/node_code_series/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/node_code_series/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=node_code_series</feedburner:origLink></item>
		<item>
		<title>Displayhack – what is it?</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/cxrDOJKaIz4/</link>
		<comments>http://www.displayhack.org/2011/about/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 11:37:59 +0000</pubDate>
		<dc:creator>Bent Stamnes</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Site info]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=9</guid>
		<description><![CDATA[Hello there, and welcome to displayhack.org! So, what's this site then? Well, there are two ways to describe it - one short, and one long. This is the short version:
Displayhack is a site for everyone participating in or enjoying real-time graphics, visual arts, motion graphics and the demoscene. Often adduced as the reason or ...]]></description>
			<content:encoded><![CDATA[<p>Hello there, and welcome to displayhack.org! So, what&#8217;s this site then? Well, there are two ways to describe it &#8211; one short, and one long. This is the short version:</p>
<blockquote><p><strong>Displayhack</strong> is a site for everyone participating in or enjoying real-time graphics, visual arts, motion graphics and the demoscene. Often adduced as the reason or motivation for expending effort toward a seemingly useless goal, the point being that the accomplished goal is a hack. As Louis Armstrong once said when asked to explain jazz: &#8220;Man, if you gotta ask you&#8217;ll never know.&#8221;</p></blockquote>
<p>..and here is the long one:</p>
<h3>Niches</h3>
<p>Niche-sites are cool. They are good at what they do, they cater to their audience, and they specialize. They&#8217;re niches after all. There are many such sites and while all good and focused, almost all of them either focus too narrow or too wide.</p>
<p>We wanted to create a site where all those interested in the demoscene, web-based graphics, motion graphics, visual arts and other visual fringe technologies could meet, discuss and inspire each other.</p>
<h3>Past, present, future</h3>
<p>As long-time demosceners, we know very well that the history of the scene is exactly that: history. If we want to play a part in the next generation of visual artistry, we need to do two things: 1) recruit, and 2) embrace. We need more people to enter the scene, actively, and we need to look outside the traditions of packaged executables downloaded to your computer. The next generation of the demoscene is already here, and it&#8217;s on the web, in movies and all around us.</p>
<p>Enter <em>Displayhack</em>. It is a site for everyone participating in or enjoying real-time graphics, graphics programming, visual arts, motion graphics and the demoscene, and aims to be a friendly and informative meeting place for beginners, seasoned professionals and everyone in between.</p>
<h3>The name</h3>
<p>So, where does the name come from? Well, as all truths, it stems from Wikipedia:</p>
<blockquote><p>A <strong>display hack</strong> is a <a title="Computer program" href="http://en.wikipedia.org/wiki/Computer_program">computer program</a> with similar purpose to a <a title="Kaleidoscope" href="http://en.wikipedia.org/wiki/Kaleidoscope">kaleidoscope</a>: to make pretty pictures (<a title="Symmetrical" href="http://en.wikipedia.org/wiki/Symmetrical">symmetrical</a> or otherwise).</p>
<p><em>&#8220;The hack value of a display hack is proportional to the esthetic value of the images times the cleverness of the algorithm divided by the size of the code.&#8221;</em></p>
<p><em><a title="Crack intro" href="http://en.wikipedia.org/wiki/Crack_intro">Crack intros</a></em>, display hacks programmed by <a title="Software cracking" href="http://en.wikipedia.org/wiki/Software_cracking">software crackers</a> for the <a title="Home computer" href="http://en.wikipedia.org/wiki/Home_computer">home computers</a> of the 1980s, evolved into what was to be known as <em><a title="Demo (computer programming)" href="http://en.wikipedia.org/wiki/Demo_%28computer_programming%29">demos</a></em> and <em><a title="Demo effect" href="http://en.wikipedia.org/wiki/Demo_effect">demo effects</a></em>. The creation of demos later became a subculture of its own, now known as the <a title="Demoscene" href="http://en.wikipedia.org/wiki/Demoscene">demoscene</a>.</p></blockquote>
<h3>Contribute</h3>
<p>We&#8217;re in the middle of adding a lot of content to the site, but what we really want to achieve is a constant flow of new content, driven by our users. If you&#8217;d like to be become a contributor, <a title="Contact" href="http://www.displayhack.org/contact/">please contact us</a> &#8211; we&#8217;d love to hear from you! To become a user, simply use your existing OpenID or SceneID &#8212; oh, and <a href="http://www.displayhack.org/forum/topic/faq-creating-a-user-on-this-site/">read the user FAQ</a> too.</p>
<p><strong>Welcome to <em>Displayhack</em>.</strong></p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=9&amp;md5=227a8c5406149d554664156190fe4877" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/cxrDOJKaIz4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/about/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/about/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=about</feedburner:origLink></item>
		<item>
		<title>Syncing your real-time graphics right</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/zIoZC4oxMWU/</link>
		<comments>http://www.displayhack.org/2011/syncing-your-real-time-graphics-right/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 19:58:15 +0000</pubDate>
		<dc:creator>Bent Stamnes</dc:creator>
				<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=408</guid>
		<description><![CDATA[


For me, as a musician and designer, the most exciting part of the visual aspects of making a demo is undoubtedly the direction, editing and synchronization with the music. The problem is of course that I'm not a coder. Enter GNU Rocket - the general purpose, ad-hoc tool that gives non-coders an intuitive interface ...]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-420" title="Scyphozoa-by-Excess3" src="http://www.displayhack.org/wp-content/uploads/Scyphozoa-by-Excess3.jpg" alt="" width="620" height="200" /></p>
<div class="alert white">Note: this article is based on the talk &#8220;GNU Rocket Science&#8221; held by Erik Faye-Lund at The Gathering 2011 as well as the personal experiences of the author.</div>
<p>For me, as a musician and designer, the most exciting part of the visual aspects of making a demo is undoubtedly the direction, editing and synchronization with the music. The problem is of course that I&#8217;m not a coder. Enter GNU Rocket &#8211; the general purpose, ad-hoc tool that gives non-coders an intuitive interface to play around, in a very powerful way.</p>
<h3>What is it?</h3>
<p><a href="http://sourceforge.net/projects/rocket/">GNU Rocket</a> is what we have given the nickname &#8220;sync tracker&#8221; &#8211; that is because all of this is commonly referred to as &#8220;syncing&#8221; in the demoscene. For anyone with a background in electronic music on the Atari, Amiga or PC using &#8220;trackers&#8221;, the concept should be very familiar. Instead of having a set of horizontal channels, like working in Logic, Pro Tools or the likes, you work vertically. Each column is a channel, and each channel consists of a series of horisontal &#8220;steps&#8221;.</p>
<p>Each step can contain a note or an effect, and when you press play, the tracker traces from top to bottom, playing each note or effect when it encounters it.</p>
<p>This is what the GNU Rocket interface looks like:</p>
<p style="text-align: center;"><a href="http://www.displayhack.org/wp-content/uploads/screenshot.jpg"><img class="aligncenter size-full wp-image-413" title="screenshot" src="http://www.displayhack.org/wp-content/uploads/screenshot.jpg" alt="" width="620" height="394" /></a></p>
<p style="text-align: left;">Instead of notes or samples, each column represents a controllable variable in the graphics engine &#8212; and that&#8217;s pretty much all there is to it. If you understand this concept then you can safely move on. If you don&#8217;t, you can watch <a href="http://www.youtube.com/watch?v=SQ5jTaXywuM">this somewhat dull video</a> where someone uses Renoise to make &#8220;music&#8221;. When he starts inputing samples &#8212; just imagine that&#8217;s a keyframe in a video. That&#8217;s right &#8211; that&#8217;s how it works.</p>
<h3>The tech</h3>
<p>GNU Rocket consists of two elements: an API and an editor. The API is non-intrusive, allowing coders to be coders, and GNU Rocket tries very hard to stay out of their way. The API is versatile, engine agnostic and anti-semantical by nature &#8211; the tool doesn&#8217;t care what you edit, everything is just floating-point variables. The downside of this is that you can&#8217;t do high level editing, but that can also be seen as a positive, because it keeps complex decision-making out of the way.</p>
<p>Now to the juicy center: the client is a network server, and the API library is a network client. That&#8217;s it. Very simple, but very powerful. This is a typical workflow:</p>
<ul>
<li>The client connects to the server and tells it what variable it uses</li>
<li>The editor sends the data for each variable it has recorded to the client</li>
<li>While both ends are running, any change done in the editor is instantly communicated to the client</li>
<li>In addition to that, some control data are also sent, including play position (&#8220;current row&#8221;) and run data (&#8220;play/pause&#8221;)</li>
<li>The control data can be expanded to incude more elements in the future</li>
</ul>
<h4>The API, explained</h4>
<p>When using the API, there are really only a few elements you need to keep track of. <strong>&#8220;sync&#8221;</strong> is the path-prefix, and the actual file-name is [prefix]_[track-name]. <strong>&#8220;localhost&#8221;</strong> and SYNC_DEFAULT_PORT is the host and port to it.</p>
<pre class="brush: cpp; title: ; notranslate">struct sync_device *rocket;
rocket = sync_create_device(&quot;sync&quot;);
if (sync_connect(&quot;localhost&quot;,
SYNC_DEFAULT_PORT)) {
/* Handle error */
}</pre>
<p>You need to implement hooks to your music-player to use GNU Rocket. It ships with example implementations for <a href="http://www.un4seen.com/">BASS by Ian Luck</a> (an excellent library &#8211; when in doubt, use it). <strong>&#8220;rbp&#8221;</strong> is &#8220;rows per beat&#8221;, a value of 8 is usually sufficient, and <strong>&#8220;sync_update&#8221;</strong> does the network updating.</p>
<pre class="brush: cpp; title: ; notranslate">static void pause(void *d, int flag)
{
/* player specific */
}
static void set_row(void *d, int row)
{
/* player specific */
}
static int is_playing(void *d)
{
/* player specific */
}
static struct sync_cb cb = {
pause, set_row, is_playing
};
/* ... */
while (1) {
  double time = /* player specific */
  double beat = time * (bpm / 60);
  double row = beat * rpb;
  int irow = (int)floor(row);
  sync_update(rocket, irow, &amp;cb, ...)
  /* ... */
}</pre>
<p><strong>&#8220;sync_track&#8221;</strong> is a handle to a variable in the track data. <strong>&#8220;sync_get_track&#8221;</strong> can only fail when loading from disk, if a track has not been (correctly) stored. The <strong>&#8220;row&#8221;</strong>-variable depends on your music-player, but is a function of the playback time, your BPM and &#8220;row rate&#8221; (i.e how many rows to have per beat in the music).</p>
<pre class="brush: cpp; title: ; notranslate">const sync_track *red_track;
red_track = sync_get_track(rocket, &quot;red&quot;);
/* ... */
while (1) {
  double row = /* ... */
  sync_update(rocket, ...);
  /* ... */
  float red;
  red = sync_get_val(red_track, row);
  /* ... */
}</pre>
<p>Now you should have a working editor-executable &#8211; congratulations! At this point I should mention that while the editor GUI is compiled for Windows, it should be very easy to port to OSX or Linux. The GNU Rocket system itself has been used in productions ranging from full-size demos, down to 64k and 4k intros. It has also been used in demos for Flash and Nintendo GameBoy Advance.</p>
<h4>Using the editor</h4>
<p>Now that we have all of the tech-talk out of the way, it&#8217;s time to actually use the editor to get some work done. The overall principles are frighteningly simple:</p>
<ol>
<li>Start the editor</li>
<li>Start the demo executable (available tracks should appear in the editor)</li>
<li>Edit tracks</li>
<li>Stop the demo, modify source code, add tracks</li>
<li>Restart demo</li>
<li>Changes and new tracks should appear</li>
<li>The demo should start up at the same position as you left it</li>
</ol>
<p>..and when the time comes to release your masterpiece to the general public:</p>
<ol>
<li>File -&gt; Remote Export</li>
<li>Build release version</li>
</ol>
<h4>Hotkeys and tricks</h4>
<p>While using the editor, these are your available hotkeys:</p>
<table width="”390″" border="”1″" cellspacing="”0″" cellpadding="”0″">
<tbody>
<tr>
<td><strong>Hotkey</strong></td>
<td><strong>Function</strong></td>
</tr>
<tr>
<td>Up/Down/Left/Right</td>
<td>Move cursor</td>
</tr>
<tr>
<td>PgUp/PgDn</td>
<td>Move cursor 16 rows up/down</td>
</tr>
<tr>
<td>Home/End</td>
<td>Move cursor to begining/end</td>
</tr>
<tr>
<td>Ctrl+Left/Right</td>
<td>Move track</td>
</tr>
<tr>
<td>Enter</td>
<td>Enter key-frame value</td>
</tr>
<tr>
<td>PgUp/PgDn</td>
<td>Move cursor 16 rows up/down</td>
</tr>
<tr>
<td>Del</td>
<td>Delete key-frame</td>
</tr>
<tr>
<td>i</td>
<td>Switch interpolation mode</td>
</tr>
<tr>
<td>Space</td>
<td>Pause/Resume demo</td>
</tr>
<tr>
<td>Shift+Up/Down/Left/Right</td>
<td>Select</td>
</tr>
<tr>
<td>Ctrl+C</td>
<td>Copy</td>
</tr>
<tr>
<td>Ctrl-V</td>
<td>Paste</td>
</tr>
<tr>
<td>Ctrl+Z</td>
<td>Undo</td>
</tr>
<tr>
<td>Shift+Ctrl+Z</td>
<td>Redo</td>
</tr>
<tr>
<td>Ctrl+B</td>
<td>Bias key-frame(s)</td>
</tr>
<tr>
<td>Shift+Ctrl+Up/Down</td>
<td>Quick bias by +/- 0.1</td>
</tr>
<tr>
<td>Ctrl+Up/Down</td>
<td>Quick-bias by +/- 1</td>
</tr>
<tr>
<td>Ctrl+PgUp/PgDn</td>
<td>Quick-bias by +/- 10</td>
</tr>
<tr>
<td>Shift+Ctrl+PgUp/PgDn</td>
<td>Quick bias by +/- 100</td>
</tr>
</tbody>
</table>
<h3>Bulding for release</h3>
<p>When making a release version, you need to export your tracks to external data-files. With the demo and editor connected, just use <em>File -&gt; Remote Export</em> in the editor. You&#8217;ll also need to define a pre-processor variable called SYNC_PLAYER in your demo source. Guard calls to <strong>&#8220;sync_connect&#8221;</strong> and <strong>&#8220;sync_update&#8221;</strong> with an <strong>#ifndef</strong> on this, because these functions do not exist when in playback-mode.</p>
<p>The hooks (&#8220;sync_cb&#8221; etc.) can also be removed if you want, and link to the player-version of the library (this is just the normal version built with <strong>SYNC_PLAYER</strong> set). Keep in mind that this differs if you&#8217;re using the .NET bindings.</p>
<p>That&#8217;s it &#8211; you&#8217;re now done with the implementation. I will write a follow-up post in the near future on how to use the tool in a good way, but for now: get integrating &#8212; <a href="http://sourceforge.net/projects/rocket/">download GNU Rocket here</a> and use it in your own projects.</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=408&amp;md5=067ceaae0c83a498c43d6e73aba82ece" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/zIoZC4oxMWU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/syncing-your-real-time-graphics-right/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/syncing-your-real-time-graphics-right/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=syncing-your-real-time-graphics-right</feedburner:origLink></item>
		<item>
		<title>Making-of: Numb Res</title>
		<link>http://feedproxy.google.com/~r/displayhack/~3/bcDKsQev5W4/</link>
		<comments>http://www.displayhack.org/2011/numb-res/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 07:13:09 +0000</pubDate>
		<dc:creator>Matt Swoboda</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Frontpage]]></category>
		<category><![CDATA[Making-of]]></category>
		<category><![CDATA[behind the scenes]]></category>
		<category><![CDATA[demoscene]]></category>
		<category><![CDATA[directx]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.displayhack.org/?p=275</guid>
		<description><![CDATA[
Begin
It was easter. We made a new demo for The Gathering 2011.Yea, that’s right – in Norway, not in Germany. I really wanted to do a new demo because I’ve been collecting new routines all winter, and it was high time they got into the wild. So about 3 weeks before easter Jani and I ...]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/23216699?title=0&amp;byline=0&amp;portrait=0&amp;color=ff000d" width="621" height="349" frameborder="0"></iframe></p>
<h3>Begin</h3>
<p>It was easter. We made a new demo for <a title="The Gathering" href="http://www.gathering.org/">The Gathering 2011</a>.Yea, that’s right – in Norway, not in Germany. I really wanted to do a new demo because I’ve been collecting new routines all winter, and it was high time they got into the wild. So about 3 weeks before easter Jani and I started bouncing ideas around (“something with fluids” was the sumtotal of that I think). Then we went on the hunt for music. As some may know, we don’t have an active musician we work with regularly in Fairlight or CNCD anymore; we have to outsource. So I dropped a message on Facebook half-jokingly asking if anyone had a spare soundtrack. I’m not sure whether that was a good idea or not but I spoke to Ruairi (RC55), who put me in touch with Tom Wright (aka <a title="stereo wildlife" href="http://stereowildlife.co.uk/" target="_blank">Stereo Wildlife</a>). He’s produced a beautiful new album and agreed to let us use one of the tracks – and even did a bit of remixing to make it fit the demo. So, music was ready from day 1. This is such a huge bonus when making a demo; it meant we could completely design around it, plan out what scenes we wanted straight away and know they’d fit.</p>
<p>The demo was envisaged as a “small project” – a relatively low budget production. Low budget meaning less development time, fewer resources. Weeks to make by a small team. Frameranger for example is a very “high budget” demo – lots of people, over a year in the making, tonnes of art assets and specifically made effects, and lots and lots of wasted work. This one is very different; there’s only one hand-modelled mesh in the whole thing that’s “rendered” properly (the head at the start and end), although there’s lots of meshes used for other things in the demo. We wanted an effect-led production. The first thing that happened was that Jani designed the numbers scene in Lightwave: creating meshes for each number, placing them in the scene, timing them and making a camera path for the whole lot. Meanwhile I was working on effect development. Then Jani developed the introduction part with the head more or less on his own, and modelled and tweaked the tracks for the fluid parts while I worked on fleshing out the numbers scene with elements and effects. Then we integrated and worked together to finish. With a week or so to go there was a touch of panic and it looked like we weren’t going to get there; but in the end we found ourselves more or less done 5 days before the competition. For once we had time to polish, tweak and optimise. Hope it shows..</p>
<p>As an aside: the Gathering was a great event for us not least because they also held the <a title="Scene.org Awards" href="http://awards.scene.org/">Scene.org Awards</a>, which recognises the best demoscene productions from last year. We got 11 nominations and after a very rock &amp; roll ceremony full of glitz and fireworks came away with 4 awards: Ceasefire for best music, Agenda Circling Forth for best effects, technical achievement and the cherry on the cake: best demo of 2010. Ooooh. Apparently we just missed out on Public’s Choice by a few points – but hey, no accounting for taste.. ;)</p>
<h3>32. Particles. Again?</h3>
<p>I’ve realised over time that I’m not really a traditional “democoder”. I’m a graphics researcher who happens to prefer to show his new work off in whatever demo we make next. That probably goes some way to explaining why I do things the way I do: researching and improving on certain areas (like particle systems or fluid dynamics. but not ribbons. bitches.). Some would say that fluids or particles are effects: you “do” fluids for a scene in a demo, then you go “do” something completely different. I don’t subscribe to that. For me the achievement in a demo like this is not to implement fluids: we first used fluid dynamics in a demo 5 years ago. The challenge is to move the field on – to do something new with it that nobody else has managed to do in realtime yet, or not on the same scale. Of course there’s a point where this gets lost on the viewer, and maybe it does just become “nice particles” to the uninitiated.</p>
<p>Although the natural reaction of some people will be “oh, particles again – nothing new!” – this is probably the biggest technical leap we’ve made for a demo since Blunderbuss. Instead of concentrating on the amount of particles and simply using them to render 3D scenes with a few modifiers on top, we concentrated on the cleverness of the particles: the simulation itself and the rendering/shading. In this demo the particles are smart. They’re going somewhere.</p>
<p>Particles are just a primitive like polygons or lines – not interesting in themselves. Creating and rendering a lot of them is easy. Making them do something interesting and look good is a completely different kettle of fish. So lets talk about what we did this time to make particles do something interesting and look good..</p>
<h3>93. Smoothed Particle Hydrodynamics (SPH)</h3>
<p><a href="http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics" target="_blank">SPH</a> is a form of fluid dynamics which uses particles for storing the fluid and the transport of the forces/densities, rather than a grid. This allows you to represent more detail at higher resolution than a grid would allow given the same memory / performance limitations, it’s not limited to a certain area of space, and it makes collisions more practical and it’s a better fit for liquid effects. It’s the scheme used in professional offline packages like Realflow, used for all those nice liquid splashy effects you see in ads and movies – which take hours to simulate, let alone render. Good SPH is for me one of those holy grails of  effects development (like realtime radiosity). The thing is, the quality and scope of effects you can do with it is directly dependent on the number of particles – and so is the difficulty in pulling it off. If you have a few thousand you can make some droplet effects; with 10s of thousands you can make some nice splashes; and with 100s of thousands or millions, you can start to make really amazing running water simulations.</p>
<p><img class="size-full wp-image-284" title="numbres1" src="http://www.displayhack.org/wp-content/uploads/numbres1.jpg" alt="" width="614" height="346" /></p>
<p>The problem with SPH in realtime is it’s really really hard. The simple explanation of the algorithm is: “take all the particles near my particle and perform some force exchange between them”. The force exchange is easy; the “all the particles near my particle” is a bitch. On GPU it’s even more of a bitch; and in 3D it becomes an order of magnitude more of a bitch.</p>
<p>Other demos have featured SPH before; <a href="http://www.pouet.net/prod.php?which=56458" target="_blank">FR-063</a> performed it on the CPU with (what looks like) between 1000-10000 particles. The current bleeding edge for 3D SPH in realtime is around 250,000 particles, working on a top end GPU using CUDA and with simple point rendering (and no effects or anything else on top). The current bleeding edge for 3D SPH on DX9 – i.e. with no compute shader / CUDA – is erm.. I dont actually think it’s been done.</p>
<p>The problem is simply the neighbourhood search. You end up with a variable amount of fast-moving particles affecting each particle, where it’s hard to pick an upper bound – so the spatial database is hard to construct. If you solve the neighbourhood search, you can solve SPH.</p>
<p>The demo features up to 500,000 particles running under 3D SPH in realtime on the GPU, with surface tension and viscosity terms; this is in combination with collisions, meshing, high end effects like MLAA and depth of field, and plenty of lighting effects. On DirectX9. It’s <em>fast</em>. Almost impossibly fast. How? We found a new approach to SPH where we can re-form the neighbourhood search term to something much easier to solve on a GPU. Meaning we can, honestly, get very close to what a program like Realflow can do over hours of simulation – but in realtime. And that, for me, is what demo coding (and realtime graphics) is all about.</p>
<p><iframe width="620" height="383" src="http://www.youtube.com/embed/-fZMqjQp4c0" frameborder="0" allowfullscreen></iframe><br />
There are 4 scenes which are directly showing “fluids” in the demo; a couple more using SPH in places for the great quality it has that it makes the particles spread out really nicely rather than bunch together randomly. In each of the fluid scenes it’s basically a load of particles dropped at the top of a very long track, and left to get on with it. The camera captures only a part of the action at any time – the great battle of “design vs showing off code” resulted in something that probably doesn’t completely sell the effect, but it does make something more enjoyable to watch. And that too is what democoding is about..</p>
<p>I thought it’d be nice to show it in isolation, so I put a couple of screenshots and a video above. Aside from that one embedded video – apparently wordpress is a little bitch and won’t let me embed more than one video link into a blog post – you can also check the reverse angles here and here. Those and the above screenshots show an initial test shot we did with 3D SPH – we drop 250,000 particles, and let them run with SPH and collisions against a mesh (handled as a signed distance field). Look, it splashes about and shit like that. All completely in realtime. Oooooooh. If nothing else, being able to run it in realtime makes it a lot easier to tweak. You get instant results – you don’t have to wait for any simulations to calculate. In these days of youtube and the prevalence of netbooks, perhaps high end realtime graphics doesn’t have the same relevance to the audience that it did 15 years ago – but it sure matters a huge amount when you’re actually making something. The benefit to the workflow is huge.</p>
<h3>12. Signed Distance Fields</h3>
<p>I touched on this for Ceasefire, but it was this production where we finally got them working and used them in anger: the use of signed distance fields for arbitrary collisions (and attraction) with particles. We take polygon meshes, convert them into signed distance fields using distance to triangle measurements and place the results in a volume texture, giving us the means for fast collision ray tests. This is absolutely invaluable when using fluid dynamics because otherwise the particles fly off merrily into space. So we have particles flowing around a head; particles flowing down a track carried by SPH; and particles being blown by a 3d fluid effect into the form of a word. All using signed distance fields.</p>
<p>We used them for a lot more besides particle effects, though. They’ve become an integral part of our rendering pipeline. That will become more apparent the next time we do something featuring a lot of solid 3D.. but they’ve opened up a lot of doors.</p>
<p>One clear example of SDF usage comes in the first “fluid” scene – falling drops collide with invisible words. This also neatly demonstrates the “art vs code” issue – we’re simulating 250,000 particles under SPH running down a long 3D track, and the camera shows a small subsection of those. The collision with the words actually uses two affectors: we used a collision node to make the particles bounce off the 3D words (using an SDF version of the mesh), which worked great – but it means you only see the top of the words.  So we added a second affector – a low weighted mesh attractor which pulls the particles towards points on the faces of the mesh. This helped the particles slowly run down and also pulls them in from 3d space towards the words. It also added to the surface tension effect by keeping them attracted to the words even after they fall off the end.</p>
<h3>65. Particle Shading</h3>
<p>In my original post on my particle system a year or more ago I talked about how we  had support for opacity shadow maps for self shadowing on particles. Since Blunderbuss we didn’t actually use that much – we’ve mainly got away with unlit particles, using the shading and lighting from the source meshes. But I’ve been working on some new techniques and had to make use of them..</p>
<p>The major problem with opacity shadow maps is depth aliasing – you only have a limited set of depth samples (16 in my case) for which to represent the scene, and it’s not enough. They tend not to be spread evenly across the particles either. So I tried a few new methods:</p>
<h3>252. Volume Shading</h3>
<p>This method borrows heavily from slice-wise volume rendering: the particles are sorted in light space by depth, nearest to furthest, and rendered in slices to composite the image. In this case though we only care about the shadow result: the values are written into the per-particle shading buffer used in the final particle render.</p>
<p>The sorted particles are rendered into the shadow map in batches – typically we used 64 batches per particle system. Per batch we additively render the batch particles into the shadow map, then project the shadow map onto the particles into the next batch: the value read from the shadow map is considered the amount of shadow on that particle from particles closer to the light.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-293" title="numbres3" src="http://www.displayhack.org/wp-content/uploads/numbres3.jpg" alt="" width="614" height="346" /><img class="aligncenter size-full wp-image-294" title="numbres4" src="http://www.displayhack.org/wp-content/uploads/numbres4.jpg" alt="" width="614" height="346" /></p>
<p>This clever bit is, this method doesn’t care about the actual depth of the particle : it only cares about the position of the particle in the sorted sequence. No depth writes are required and transparency is supported without any problems. One additional benefit of the technique is that we can blur the shadow map a bit after each batch, giving a scattering effect. If one had the power to do it and could render one particle per batch, it’d give a perfect shadowing result. As it is, the batch sizes give some slice aliasing.</p>
<p>Unfortunately the slice aliasing was too much of a problem with large sytems and the technique is also a bit too slow – and generates a lot of render target swaps. So I came up with something better..</p>
<h3>15. “Stochastic” Shadow Mapping</h3>
<p>This isn’t the same as the stochastic shadow mapping paper that was recently presented, but the name makes a certain amount of sense for the effect anyway.  The basic idea is something I’ve tried a few times on and off since 2009. The idea is that if your particles don’t overlap pixels in view space, you could render them as solid – using regular shadowmapping and lighting techniques. Of course this is rarely the case in a render – because particle systems rely on lots of small elements overlapping and blending  to look solid and nice. However, what if you do render them as single pixels and make them not overlap, and then perform a full screen 2D operation to upscale each point and make them overlap and blend?</p>
<p>We applied that approach to shadow maps generated from particles. The particles are rendered as single points to a very large shadow map; this gives us a reasonable chance that the particles won’t overlap. It’s just like a spatial hash – with a very simple hashing function and no collision handling.. Then, when sampling, we read from the map using a large kernel and sum up the amount of filled pixels which pass the shadow map test to give a shadowing result.</p>
<p><img src="http://www.displayhack.org/wp-content/uploads/numbres5.jpg" alt="" title="numbres5" width="614" height="346" class="aligncenter size-full wp-image-298" /></p>
<p>But there’s a twist: in order to improve the quality, cope with hash collisions and reduce aliasing, we perform a temporal reprojection step. When writing the shadow map each frame a random sub-pixel offset is applied to each particle which varies every frame; this means we get a different set of collisions, so different particles become visible each frame. Then when sampling the shadow map we blend the result with the previous frame, so the results adjust smoothly over time. By combining these two things we get a very nice, soft, reasonably alias-free shadow solution which is also efficient to render. No sorting required. The final shadow value per particle is written into a buffer and used at particle render time.</p>
<p>I also experimented with the technique for the actual rendering of the particles to the main frame – rendering single points with Z test and blurring the buffer out, with some per-pixel sorting during the composite, to create softened particles but without the need for a full particle sort. Unfortunately it didn’t give us the visual fidelity we needed; we relied on the blending of particles, the variable sizes and the sprites used. Could be more applicable in a future project though.</p>
<h3>536. Meshing (Marching Cubes)</h3>
<p>I suppose it’s the obvious step, isn’t it. Democoders love metaballs. Being able to render particles as meshes using metaballs is something we’ve wanted to do for ages because it moves us towards the “liquid” look – the Realflow-style look. We’ve been here before: in Frameranger we rendered around 50,000 metaballs in realtime by generating a potential field, converting it into a signed distance field and raymarching it. Results were promising but not perfect: being able to generate an actual triangle mesh has some side benefits, like being able to post process the mesh and adjust it with tension – something we really wanted to do to get closer to that Realflow look I keep going on about.<br />
Marching cubes gives two issues to solve: generating the potentials, and then triangulating them. We already worked out how to generate the potentials some time ago for Frameranger, although a bit of work was required to scale it up to 250,000 particles. </p>
<p>The second part is more difficult: you need to generate an arbitrary amount of geometry data from that potential field with triangle and vertex counts that change every frame. Naturally, we could quite easily make an implementation which just generates the worst case: treat every cell in the volume as if it was contributing triangles, then write degenerates for the invalid ones. That actually works – but it’s prohibitive for large volumes. One cell can contribute up to 5 triangles, and with a 128^3 volume we’d be looking at 10 million triangles – which isn’t great. 256^3 volumes would effectively be impossible. What we need is a way to only process and send triangles for the cells that are active.</p>
<p>This is problematic because we can’t generate index or vertex buffers on the GPU, we can’t generate drawcalls on the GPU (so we can’t vary how many primitives are rendered on the GPU) and we can’t use the CPU – because the potential field is on the GPU and it’d be far too slow to get it back to CPU. And even if we could, the CPU probably isn’t up to the task of generating the geometry fast enough anyway. And even if it was, we’d have to send all the triangle data back to the GPU again. So we’re stuck with the GPU – and yet we don’t have a way to vary the number of cells we render triangles for.</p>
<p><img src="http://www.displayhack.org/wp-content/uploads/numbres6.jpg" alt="" title="numbres6" width="614" height="346" class="aligncenter size-full wp-image-299" /></p>
<p>It seems impossible. However, Gernot Ziegler came up with a nice solution a while ago: histopyramids. This is a way of performing stream compaction on the GPU: it takes a big sparse buffer, and moves all the filled elements to the start of the buffer. A bit like a sort, but much more efficient. This gives us exactly what we need: we generate the (sparse) potential grid and use histopyramid compaction to move all the filled elements to the start. Then we use an occlusion query to count the number of active cells and use the CPU to generate batches which give enough triangles for the count to generate. The actual vertices are generated using a pixel shader and vertex texture fetch is used to read them.</p>
<p>Result!</p>
<h3>4. Bokeh Glows</h3>
<p>I’ve had this effect on the back burner for a few years but finally got to actually finishing it up.. Bokeh is the term relating to the effect of circular or shaped highlights in a depth of field effect, caused by inaccuracies in the shape of the lens of a camera. Or something. They make DOF look really nice. I’ve tried before by using a really big circular kernel for a regular DOF effect with an HDR input and leaving it at that and it actually does work, but I wanted to see if I could get some shaped bokehs and really overblow it. So I tried something with point sprites.</p>
<p><img src="http://www.displayhack.org/wp-content/uploads/numbres7.jpg" alt="" title="numbres7" width="614" height="346" class="aligncenter size-full wp-image-300" /></p>
<p>The basic idea is to work out where on screen bokehs would happen, and render point sprites at those points. I did this using the following method:</p>
<ul>
<li>Use those 2d positions to read a blurred version of the original frame. Perform some thresholding to pick out the points which pass. Generate colour values for the points.</li>
<li>Temporally smooth positions and colours using positions from last frame, apply some attack and decay.</li>
<li>Render a load of point sprites using vertex texture fetch to read the positions and colours, rendering the sprites to the screen. (With some additional magic to make it look good.)</li>
</ul>
<h3>72. Post Process Antialiasing (MLAA)</h3>
<p>This is the first demo since 2009 (Frameranger, in fact) that we’ve released which actually features polygons being rendered as polygons. Happily, time has moved on, and so has our renderer. One of the major bugbears I had with the deferred renderer is lack of antialiasing – but fortunately a whole bunch of post process antialiasing techniques got invented in the last couple of years. MLAA is the technique du jour, and we use an implementation in our renderer. It’s great.</p>
<p>We do two little twists in our version to make it cool: firstly we use a lot of stencil optimisation so only the active edges get the big-ass shader applied to do the actual MLAA (or in fact get any of the process after the edge detect applied). And secondly.. there’s an ugly problem with MLAA in that it actually cocks up quite badly in a certain case. The technique relies on checking for horizontal or vertical edges. But where you have a pixel which is both a horizontal and vertical edge, it messes it up. Which breaks about 1/4 of the diagonal edges you have to deal with, so its pretty noticable. Our oh so clever technique for fixing that is.. do the MLAA twice.  The second time we flip the whole image in x and y, then MLAA it and flip it back. Genius huh? .. no? Well, it makes the polygonal scenes look good, and fortunately the stenciled version is so fast the extra hit isnt really noticable.</p>
<h3>42. Stereoscopic 3D</h3>
<p>We really wanted to do something with 3D for a while, but sadly we dont have any true 3D hardware (*cough* donations please *cough*). We decided quite early on that we were going to go for a pretty much black &#038; white look – so it would actually be feasible to use the good old red / cyan anaglyph method. 3D isn’t as easy as just turning it on, though. It takes some effort to make it work well, give a good effect and not strain your eyes. We tuned it quite carefully and the setup of the scenes really helps – the first scene is slow and quite static so it lets your eyes adjust, the camera movements are quite smooth and in a single direction so they’re easy to track, and so on and so on.</p>
<p>Do watch the demo in 3D, it’s really made for it. We’re going to make a proper HD 3D video with left &#038; right splits soon for those with real 3d setups.</p>
<h3>End</h3>
<p>I guess what’s interesting for me about this demo is that it was so much easier to make than many we’ve done. It just kind of came together; we started early enough, we got the music at the start, we  didn’t have any major problems, nobody disappeared or dropped out, everything showed up on time, we didn’t completely overstretch ourselves and come up with some ideas that couldn’t be done, and we had time at the end to go over it and tweak and polish things, and we’re really happy with how it turned out. It’s like the way it’s supposed to go but never does. It doesn’t work for everyone (not very bombastic, you see) but it seems the people who got it really got it and like it, which is what matters. Maybe we’ve actually cracked it.. or maybe next time’ll be a royal screwup. Have to wait and see..</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.displayhack.org/?flattrss_redirect&amp;id=275&amp;md5=2b2b397a2c5d5f00fd8c990ff0cd93fb" title="Flattr" target="_blank"><img src="http://www.displayhack.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p><img src="http://feeds.feedburner.com/~r/displayhack/~4/bcDKsQev5W4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.displayhack.org/2011/numb-res/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.displayhack.org/2011/numb-res/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=numb-res</feedburner:origLink></item>
	</channel>
</rss>

