<?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>Lost in the Triangles</title>
	
	<link>http://aras-p.info/blog</link>
	<description>Random thoughts of a triangle pusher</description>
	<lastBuildDate>Wed, 04 Nov 2009 14:42:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/LostInTheTriangles" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Deferred Cascaded Shadow Maps</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/QQtW2npwfKI/</link>
		<comments>http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 14:42:08 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[rendering]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=434</guid>
		<description><![CDATA[Reading &#8220;Rendering Technology at Black Rock Studios&#8221; made me realize that cascaded shadow maps I did 2+ years ago in Unity 2.0 are probably called &#8220;deferred shadowing&#8221;. Since I never wrote how they are done&#8230; here:
The process is roughly this (all of this is DX9 level tech on PCs; later tech or consoles could and [...]]]></description>
			<content:encoded><![CDATA[<p>Reading &#8220;<a href="http://www.bungie.net/News/content.aspx?type=topnews&#038;link=Siggraph_09">Rendering Technology at Black Rock Studios</a>&#8221; made me realize that cascaded shadow maps I did 2+ years ago in Unity 2.0 are <em>probably</em> called &#8220;deferred shadowing&#8221;. Since I never wrote how they are done&#8230; here:</p>
<p>The process is roughly this (all of this is DX9 level tech on PCs; later tech or consoles could and should use more optimizations):</p>
<ol>
<li>Render shadow map cascades. All of them packed into one shadow map via viewports.</li>
<li>Collect shadows into screen sized render target. This is the shadow term.</li>
<li>Blur the shadow term.</li>
<li>In regular forward rendering, use shadow term in screen space.</li>
</ol>
<p>More detail:</p>
<p><strong>Render Shadow Cascades</strong></p>
<p>Nothing fancy here. All cascades packed into a single shadow map. For example two 512&#215;512 cascades would be packed into 1024&#215;512 shadow map side by side.</p>
<p><strong>Screen-space Shadow Term</strong></p>
<p>Render all shadow receivers with a shader that &#8220;collects&#8221; shadow map term. In effect, shadows from all cascades are collected into a screen-sized texture. After this step, original cascaded shadowmaps are not needed anymore.</p>
<p>Unity supports up to 4 shadow map cascades, which neatly fit into a float4 register in the pixel shader. Correct cascade is sampled just once, <em>without</em> using static or dynamic branching. Pixel shader pseudocode:</p>
<blockquote><pre>
float4 near = float4 (z >= _LightSplitsNear);
float4 far = float4 (z < _LightSplitsFar);
float4 weights = near * far;
float2 coord =
    i._ShadowCoord[0] * weights.x +
    i._ShadowCoord[1] * weights.y +
    i._ShadowCoord[2] * weights.z +
    i._ShadowCoord[3] * weights.w;
float sm = tex2D (_ShadowMapTexture, coord.xy).r;
</pre>
</blockquote>
<p>Additionally, shadow fadeout is applied here (shadows in Unity can be cast up to specified distance from the camera, and they fade out when approaching that distance).</p>
<p>After this I end up having shadow term in screen space. Note that here I do not do any shadow map filtering; that is done in screen space later.</p>
<p>On PCs in DX9 there is (or there was?) no easy/sane way to read depth buffer in the pixel shader, so while collecting shadows the shader also outputs depth packed into two channels of the render target.</p>
<p><strong>Screen-space Shadow Blur</strong></p>
<p>Previous step results in screen space shadow term and depth. Shadow term is blurred into another render target, using a spatially varying Poisson disc-like filter.</p>
<p>Filter size depends on depth (shadow boundaries closer to the camera are blurred more). Filter also discards samples if difference in depth is larger <em>than something</em>, to avoid blurring over object boundaries. It's not totally robust, but seems to work quite well.</p>
<p><strong>Using shadow term in forward rendering</strong></p>
<p>In forward rendering, this blurred shadow term texture is used. Here shadow term already has filtering &#038; fadeout applied, and the shaders do not need to know anything about shadow cascades. Just read pixel from the texture and use it in lighting computation. Done!</p>
<p><strong>Fin</strong></p>
<p>Back then I didn't know this would be called "deferred" <em>(that would probably have scared me away!)</em>. I don't know if this approach is any good, but so far it works quite well for Unity needs. Also, reduces shader permutation count a lot, which I like.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/QQtW2npwfKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/</feedburner:origLink></item>
		<item>
		<title>Fixing bugs, in Tom Waits’ words</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/3f112EoN4DQ/</link>
		<comments>http://aras-p.info/blog/2009/09/20/fixing-bugs-in-tom-waits-words/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 07:19:27 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=431</guid>
		<description><![CDATA[Mixing a sprint of bug fixing before the release and Tom Waits&#8217; music results in interesting combination. For example, Crossroads describes bug fixing process perfectly:
And that&#8217;s where ol&#8217; George found himself out there at the FogBugz
Fixin&#8217; the devil&#8217;s bugs
Now, a man figures it&#8217;s his bugs and he&#8217;ll assign whom he wants
But it don&#8217;t always work [...]]]></description>
			<content:encoded><![CDATA[<p>Mixing a sprint of bug fixing before the release and Tom Waits&#8217; music results in interesting combination. For example, <a href="http://en.wikipedia.org/wiki/The_Black_Rider_(album)">Crossroads</a> describes bug fixing process perfectly:</p>
<blockquote><p>And that&#8217;s where ol&#8217; George found himself out there at the FogBugz<br />
Fixin&#8217; the devil&#8217;s bugs<br />
Now, a man figures it&#8217;s his bugs and he&#8217;ll assign whom he wants<br />
But it don&#8217;t always work out that way<br />
You see, some bugs are special for a certain target<br />
A certain platform, or a certain person<br />
And no matter whom you&#8217;re assignin&#8217;, that&#8217;s where the bug &#8216;ll end up<br />
And in the moment of assigning your mouse turns into a dowser&#8217;s wand<br />
And clicks where the bug wants to go.</p></blockquote>
<p>Uhm. Yeah.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/3f112EoN4DQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/09/20/fixing-bugs-in-tom-waits-words/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/09/20/fixing-bugs-in-tom-waits-words/</feedburner:origLink></item>
		<item>
		<title>Strided blur and other tips for SSAO</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/jEnE5ZIkliA/</link>
		<comments>http://aras-p.info/blog/2009/09/17/strided-blur-and-other-tips-for-ssao/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 07:59:01 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[gpu]]></category>
		<category><![CDATA[papers]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=409</guid>
		<description><![CDATA[If you&#8217;re new to SSAO, here are good overview blog posts: meshula.net and levelofdetail. Some tips and an idea on strided blur below.
Bits and pieces I found useful

SSAO can be generated at a smaller resolution than screen, with depth+normals aware upsample/blur step.
If random offset vector points away from surface normal, flip it. This makes random [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re new to SSAO, here are good overview blog posts: <a href="http://meshula.net/wordpress/?p=145">meshula.net</a> and <a href="http://levelofdetail.wordpress.com/2008/02/10/2007-the-year-ssao-broke/">levelofdetail</a>. Some tips and an idea on strided blur below.</p>
<p><span id="more-409"></span><strong>Bits and pieces I found useful</strong></p>
<ul>
<li>SSAO can be generated at a smaller resolution than screen, with depth+normals aware upsample/blur step.</li>
<li>If random offset vector points away from surface normal, flip it. This makes random vectors be in the upper hemisphere, which reduces false occlusion on flat surfaces. Of course this requires having surface normals.</li>
<li>When generating random vectors for your AO kernel:
<ul>
<li>Generate vectors <i>inside</i> unit sphere (not <i>on</i> unit sphere).</li>
<li>Use energy minimization to distribute your samples better, especially at low sample counts. See <a href="http://www.malmer.nu/index.php/2008-04-11_energy-minimization-is-your-friend">malmer.ru</a> blog post.</li>
</ul>
</li>
<li>In your AO blurring/upsampling step: no need to sample each pixel for blur. Just skip some of them, i.e. make kernel offsets larger. See below.</li>
</ul>
<p><strong>Strided blur for AO</strong></p>
<p>Normally you&#8217;d blur AO term using some sort of standard blur, for example separable Gaussian: horizontal blur, followed by vertical blur. How one can imagine horizontal blur kernel:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/blur1.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/blur1.png" alt="Horizontal Blur Kernel" title="Horizontal Blur Kernel" width="291" height="51" class="alignnone size-full wp-image-420" /></a></p>
<p>Here&#8217;s how <a href="http://runevision.com/">Rune</a> taught me how to blur better:</p>
<blockquote>
<dl>
<dt>Rune:</dt>
<dd>The other thing is the blur. I tried to make the blur 4 times stronger, and it looks much better IMO without any artifacts I could see. I could even use 4x downsampling with that blur amount and still get acceptable results.</dd>
<dt>Aras:</dt>
<dd>how did you make it 4x stronger? <i>(I was going to say that blur step is already quite expensive, and I don&#8217;t want to add more samples to make it even more expensive, yadda yadda)</i></dd>
<dt>Rune:</dt>
<dd>m_SSAOMaterial.SetVector (&#8221;_TexelOffsetScale&#8221;, m_IsOpenGL ?<br />
	&nbsp;&nbsp;new Vector4 (<b>4</b>,0,1.0f/m_Downsampling,0) :<br />
	&nbsp;&nbsp;new Vector4 (<b>4.0f</b>/source.width,0,0,0));<br />
	And similar for vertical.</dd>
<dt>Aras:</dt>
<dd>hmm. that&#8217;s strange :)</dd>
<dt>Rune:</dt>
<dd>I have no idea what I&#8217;m doing of course but it looks good.</dd>
<dt>Aras:</dt>
<dd>so this way it does not do Gaussian on 9&#215;9 pixels, but instead only takes each 4th pixel. Wider area, but&#8230; it should not work! :)</dd>
<dt>Rune:</dt>
<dd>It creates a very fine pattern at pixel level but it&#8217;s way more subtle than the noise you get otherwise.</dd>
<dt>Aras:</dt>
<dd>ok <i>(hides in the corner and weeps)</i></dd>
</dl>
</blockquote>
<p>So yeah. The blur kernel can be &#8220;spread&#8221; to skip some pixels, effectively resulting in a larger blur radius for the same sample count:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/blur2.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/blur2.png" alt="Blur with 2 pixel stride" title="Blur with 2 pixel stride" width="291" height="51" class="alignnone size-full wp-image-421" /></a></p>
<p>Or even this:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/blur3.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/blur3.png" alt="Blur with 3 pixel stride" title="Blur with 3 pixel stride" width="291" height="51" class="alignnone size-full wp-image-422" /></a></p>
<p>Yes, it&#8217;s not correct blur. <strong>But that&#8217;s okay</strong>, we&#8217;re not building nuclear reactors that depend on SSAO blur being accurate. <em>If you are, SSAO is probably a wrong approach anyway, I&#8217;ve heard it&#8217;s not that useful for nuclear stuff</em>.</p>
<p>I&#8217;m not sure how this blur should be called. Strided blur? Interleaved blur? Interlaced blur? Or maybe everyone is doing that already and it has a well established name? Let me know.</p>
<p>Some images of blur in action. Raw AO term (very low &#8211; 8 &#8211; sample count and increased contrast on purpose):<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO1raw.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO1raw-500x270.png" alt="Raw AO at low sample count" title="Raw AO at low sample count" width="500" height="270" class="alignnone size-medium wp-image-412" /></a></p>
<p>Regular 9&#215;9 blur (does not blur over depth+normals discontinuities):<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO2blur.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO2blur-500x270.png" alt="Blurred AO" title="Blurred AO" width="500" height="270" class="alignnone size-medium wp-image-413" /></a></p>
<p>Blur that goes in 2 pixel stride (effectively 17&#215;17):<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO3blur2.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO3blur2-500x271.png" alt="Blurred AO with stride 2" title="Blurred AO with stride 2" width="500" height="271" class="alignnone size-medium wp-image-414" /></a><br />
It does create a fine interleaved pattern because it skips pixels. But you get wider blur!<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO3blur2mag.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO3blur2mag.png" alt="Blurred AO with stride 2, magnified" title="Blurred AO with stride 2, magnified" width="256" height="244" class="alignnone size-full wp-image-415" /></a></p>
<p>Blur that goes in 3 pixel stride (effectively 25&#215;25):<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO4blur3.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO4blur3-500x269.png" alt="Blurred AO with stride 3" title="Blurred AO with stride 3" width="500" height="269" class="alignnone size-medium wp-image-416" /></a><br />
At 3 pixel stride the artifacts are becoming apparent. But hey, this is very<br />
low AO sample count, increased contrast and no textures in the scene.<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO4blur3mag.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO4blur3mag.png" alt="Blured AO with stride 3, magnified" title="Blured AO with stride 3, magnified" width="256" height="244" class="alignnone size-full wp-image-417" /></a></p>
<p>For sake of completeness, the same raw AO term, but computed at 2&#215;2 smaller resolution (still using low sample count etc.):<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO5down2.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO5down2-500x270.png" alt="AO computed at lower resolution" title="AO computed at lower resolution" width="500" height="270" class="alignnone size-medium wp-image-418" /></a></p>
<p>Now, 2&#215;2 smaller AO, blurred with 3 pixels stride:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/AO6down2blur3.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/AO6down2blur3-499x272.png" alt="AO at lower resolution, blurred with 3 pixel stride" title="AO at lower resolution, blurred with 3 pixel stride" width="499" height="272" class="alignnone size-medium wp-image-419" /></a></p>
<p>Happy blurring!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/jEnE5ZIkliA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/09/17/strided-blur-and-other-tips-for-ssao/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/09/17/strided-blur-and-other-tips-for-ssao/</feedburner:origLink></item>
		<item>
		<title>Usability depends on context!</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/TdNPi_S4JfU/</link>
		<comments>http://aras-p.info/blog/2009/09/14/usability-depends-on-context/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 13:16:02 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=387</guid>
		<description><![CDATA[Here&#8217;s a little story on how usability decisions need to depend on context.
In Unity editor pretty much any window can be &#8220;detached&#8221; from the main window. An obvious use case is putting it onto a separate monitor. But of course you can just end up having a ton of detached windows overlapping each other.
Here I [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little story on how usability decisions need to depend on context.</p>
<p>In Unity editor pretty much any window can be &#8220;detached&#8221; from the main window. An obvious use case is putting it onto a separate monitor. But of course you can just end up having a ton of detached windows overlapping each other.</p>
<p>Here I have four windows in total on OS X:<span id="more-387"></span><br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/OSXOverlapped.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/OSXOverlapped-500x324.jpg" alt="Overlapped Windows on OS X" title="Overlapped Windows on OS X" width="500" height="324" class="size-medium wp-image-389" /></a></p>
<p>Here I have four windows on Windows:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/WinOverlapped.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/WinOverlapped-500x312.jpg" alt="Overlapped Windows on Windows" title="Overlapped Windows on Windows" width="500" height="312" class="size-medium wp-image-393" /></a></p>
<p>However, users of OS X and Windows are used to applications behaving differently.</p>
<p>On OS X, it is <em>very</em> common that a single application has many overlapping windows. Usually users don&#8217;t have problems finding their windows either, thanks to Exposé. Press a key, voilà, here they are:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/OSXExpose.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/OSXExpose-500x316.jpg" alt="Exposé on OS X" title="Exposé on OS X" width="500" height="316" class="size-medium wp-image-388" /></a></p>
<p>On Windows, there is no Exposé. So there&#8217;s a problem: when a detached window is obscured by another window, how do you get to it? One would ask &#8220;well, what&#8217;s wrong in having windows partially overlapped, like in above screenshot?&#8221;, to which I&#8217;d say &#8220;you&#8217;re a Mac user&#8221;.</p>
<p>Windows users do not have a ton of windows on screen. They tend to maximize the application they are currently working with. <em>I was doing this myself</em> all the time, and it took 3 years of Mac laptop usage before I stopped maximizing everything on my Windows box!</p>
<p>So what a typical Windows user might see when using Unity is this. Now, where are the other three detached windows?<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/WinMaximized.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/WinMaximized-500x312.jpg" alt="Maximized" title="Maximized" width="500" height="312" class="size-medium wp-image-392" /></a></p>
<p>On Windows, it is <em>very uncommon</em> for a single application to have many overlapped windows. When an application does that, the &#8220;detached&#8221; windows are always positioned on top of the main window. There are some applications that do not do this (yes I&#8217;m looking at you GIMP), and almost everyone is not happy with their usability.</p>
<p>So we decided to take this context into account. Windows users do not have Exposé, <em>and</em> they expect &#8220;detached&#8221; windows to be always on top of the main window. Unity 2.6 will do this soon.<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/WinInFront.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/WinInFront-500x312.jpg" alt="In Front on Windows" title="In Front on Windows" width="500" height="312" class="size-medium wp-image-391" /></a></p>
<p>Of course, you still can dock all the windows together and this whole &#8220;windows are obscured by other windows&#8221; issue goes away:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/09/WinDocked.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/09/WinDocked-500x312.jpg" alt="Docked on Windows" title="Docked on Windows" width="500" height="312" class="size-medium wp-image-390" /></a></p>
<p><em>Hmm&#8230; I think the screenshots above show two new big features in upcoming Unity 2.6. Preemptive note: UI of the stuff above is not final. Anything might change, don&#8217;t become attached to any particular pixel!</em></p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/TdNPi_S4JfU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/09/14/usability-depends-on-context/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/09/14/usability-depends-on-context/</feedburner:origLink></item>
		<item>
		<title>Talks &amp; Demos from Assembly 2009</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/sq6GHFSdDL4/</link>
		<comments>http://aras-p.info/blog/2009/08/21/talks-demos-from-assembly-2009/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 07:10:34 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[demos]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=381</guid>
		<description><![CDATA[I went to Assembly 2009 demoparty this year.
No demo submissions, but I did a seminar presentation about developing graphics technology for small games (PDF slides). Mostly on hardware statistics, GPU features, testing and stability:
]]></description>
			<content:encoded><![CDATA[<p>I went to <a href="http://www.assembly.org/summer09/?set_language=en">Assembly 2009</a> demoparty this year.</p>
<p>No demo submissions, but I did a seminar presentation about developing graphics technology for small games (<a href='http://aras-p.info/texts/files/Assembly09-Aras-GfxTech.pdf'>PDF slides</a>). Mostly on hardware statistics, GPU features, testing and stability:</p>
<p><span id="more-381"></span><object width='504' height='284'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=6128236&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=6128236&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='504' height='284'></embed></object><br /><a href='http://vimeo.com/6128236'>View on Vimeo</a>.</p>
<p>However, the <strong>awesome talk was given by ReJ</strong>: low level iPhone (pre-3GS) rendering details (<a href='http://blogs.unity3d.com/wp-content/uploads/2009/08/Assembly09-iPhone-Learning-GPU-from-Driver-Code.pdf'>PDF slides</a>). Inner workings of iPhone&#8217;s GPU, OpenGL ES drivers, command buffers, VFP assembly and so on. Bringing assembly back to the Assembly, yeah!<br />
<object width='504' height='284'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=6064955&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=6064955&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='504' height='284'></embed></object><br /><a href='http://vimeo.com/6064955'>View on Vimeo</a>.</p>
<p>If you&#8217;re going to watch some demos from Assembly 2009, make sure to see:</p>
<ul>
<li><a href="http://capped.tv/cncd_orange_fairlight-frameranger">Frameranger</a> (1st place demo). Rocked the big screen! Seems somewhat unfinished though.</li>
<li><a href="http://capped.tv/united_force_digital_dynamite-the_golden_path">The Golden Path</a> (3rd place demo) &#8211; for something fresh. Also, a good way to disprove the saying that &#8220;the winners don&#8217;t take drugs&#8221; :)</li>
<li><a href="http://capped.tv/youth_uprising_mlat_design_out-muon_baryon">Muon Baryon</a> (1st place 4 kilobyte intro) &#8211; that&#8217;s what kids do with sphere marching on the GPU these days.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/sq6GHFSdDL4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/08/21/talks-demos-from-assembly-2009/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/08/21/talks-demos-from-assembly-2009/</feedburner:origLink></item>
		<item>
		<title>Compact Normal Storage for small g-buffers</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/cAlPr_berJI/</link>
		<comments>http://aras-p.info/blog/2009/08/04/compact-normal-storage-for-small-g-buffers/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 09:39:51 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[d3d]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=377</guid>
		<description><![CDATA[I&#8217;ve been experimenting with compact storage of view space normals for small g-buffers. Think about storing depth and normal in a single 8 bit/channel RGBA texture.
Here are my findings &#8211; with error visualization and shader performance numbers for some GPUs.
If you know any other method to encode/store normals in a compact way, please let me [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with compact storage of view space normals for small g-buffers. Think about storing depth and normal in a single 8 bit/channel RGBA texture.</p>
<p><a href="http://aras-p.info/texts/CompactNormalStorage.html"><strong>Here are my findings</strong></a> &#8211; with error visualization and shader performance numbers for some GPUs.</p>
<p>If you know any other method to encode/store normals in a compact way, please let me know!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/cAlPr_berJI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/08/04/compact-normal-storage-for-small-g-buffers/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/08/04/compact-normal-storage-for-small-g-buffers/</feedburner:origLink></item>
		<item>
		<title>Encoding floats to RGBA – the final?</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/1KfT-nJv9Ak/</link>
		<comments>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 12:58:08 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[gpu]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=369</guid>
		<description><![CDATA[The saga continues! In short, I need to pack a floating point number in [0..1) range into several channels of 8 bit/channel render texture. My previous approach is not ideal.
Turns out some folks have figured out an approach that finally seems to work.
Here it is for my own reference:

gamedev.net forum post by gjaegy
Suggestion right there [...]]]></description>
			<content:encoded><![CDATA[<p>The saga continues! In short, I need to pack a floating point number in [0..1) range into several channels of 8 bit/channel render texture. My <a href="http://aras-p.info/blog/2008/06/20/encoding-floats-to-rgba-again/">previous approach</a> is not ideal.</p>
<p>Turns out some folks have figured out an approach that finally <em>seems</em> to work.</p>
<p>Here it is for my own reference:</p>
<ul>
<li><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=442138&#038;whichpage=1&#2936108">gamedev.net forum post by gjaegy</a></li>
<li>Suggestion <a href="http://aras-p.info/blog/2008/06/20/encoding-floats-to-rgba-again/#comment-16380">right there</a> on my previous blog post comments</li>
<li>Repost <a href="http://www.gamerendering.com/2008/09/25/packing-a-float-value-in-rgba/">gamerendering blog</a></li>
<li>Repost on <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=463075&#038;whichpage=1&#3054958">gamedev.net forums</a> again.</li>
</ul>
<p>So here&#8217;s the proper way:</p>
<blockquote>
<pre>inline float4 EncodeFloatRGBA( float v ) {
  float4 enc = float4(1.0, 255.0, 65025.0, 160581375.0) * v;
  enc = frac(enc);
  enc -= enc.yzww * float4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);
  return enc;
}
inline float DecodeFloatRGBA( float4 rgba ) {
  return dot( rgba, float4(1.0, 1/255.0, 1/65025.0, 1/160581375.0) );
}</pre>
</blockquote>
<p>That is, the difference from the <a href="http://aras-p.info/blog/2008/06/20/encoding-floats-to-rgba-again/">previous approach</a> is that the &#8220;magic&#8221; (read: hardware dependent) bias is replaced with subtracting next component&#8217;s encoded value from the previous component&#8217;s encoded value.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/1KfT-nJv9Ak" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/</feedburner:origLink></item>
		<item>
		<title>Implementing fixed function T&amp;L in vertex shaders</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/upJbSv7tvy8/</link>
		<comments>http://aras-p.info/blog/2009/06/09/implementing-fixed-function-tl-in-vertex-shaders/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 06:08:50 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[d3d]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=364</guid>
		<description><![CDATA[Almost half a year ago I was wondering how to implement T&#038;L in vertex shaders.
Well, finally I implemented it for upcoming Unity 2.6. I wrote some sort of a technical report here.
In short, I&#8217;m combining assembly fragments and doing simple temporary register allocation, which seems to work quite well. Performance is very similar to using [...]]]></description>
			<content:encoded><![CDATA[<p>Almost half a year ago I was wondering <a href="http://aras-p.info/blog/2009/01/22/fixed-function-lighting-in-vertex-shader-how/">how to implement T&#038;L in vertex shaders</a>.</p>
<p>Well, finally I implemented it for upcoming Unity 2.6. I wrote some sort of a <a href="http://aras-p.info/texts/VertexShaderTnL.html"><strong>technical report here</strong></a>.</p>
<p>In short, I&#8217;m combining assembly fragments and doing simple temporary register allocation, which seems to work quite well. Performance is very similar to using fixed function (I know it&#8217;s implemented as vertex shaders internally by the runtime/driver) on several different cards I tried (Radeon HD 3xxx, GeForce 8xxx, Intel GMA 950).</p>
<p>What was unexpected: the most complex piece is not the vertex lighting! Most complexity is in how to route/generate texture coordinates and transform them. Huge combination explosion there.</p>
<p>Otherwise &#8211; I like! Here&#8217;s a link to the <a href="http://aras-p.info/texts/VertexShaderTnL.html">article again</a>.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/upJbSv7tvy8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/06/09/implementing-fixed-function-tl-in-vertex-shaders/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/06/09/implementing-fixed-function-tl-in-vertex-shaders/</feedburner:origLink></item>
		<item>
		<title>Shaders must die, part 3</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/e-ICN_U48Q8/</link>
		<comments>http://aras-p.info/blog/2009/05/10/shaders-must-die-part-3/#comments</comments>
		<pubDate>Sun, 10 May 2009 15:24:17 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[gpu]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=350</guid>
		<description><![CDATA[Continuing the series (see Part 1, Part 2)&#8230;
Got different lighting models (BRDFs) working. Without further ado, code snippets that produce real actual working shaders that work with lights &#038; shadows and whatnot:
Simple Lambert (single color):
Properties
    Color _Color
EndProperties
Surface
    o.Albedo = _Color;
EndSurface
Lighting Lambert


Let&#8217;s add a texture:
Properties
    2D _MainTex
 [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series (see <a href="http://aras-p.info/blog/2009/05/05/shaders-must-die/">Part 1</a>, <a href="http://aras-p.info/blog/2009/05/07/shaders-must-die-part-2/">Part 2</a>)&#8230;</p>
<p>Got different lighting models (BRDFs) working. Without further ado, code snippets that produce real actual working shaders that work with lights &#038; shadows and whatnot:</p>
<p><span id="more-350"></span>Simple Lambert (single color):</p>
<blockquote><pre>Properties
    Color _Color
EndProperties
Surface
    o.Albedo = _Color;
EndSurface
Lighting Lambert
</pre>
</blockquote>
<p>Let&#8217;s add a texture:</p>
<blockquote><pre>Properties
    2D _MainTex
    Color _Color
EndProperties
Surface
    o.Albedo = SAMPLE(_MainTex) * _Color;
EndSurface
Lighting Lambert</pre>
</blockquote>
<p>Change light model to Half-Lambert (a.k.a. wrapped diffuse):</p>
<blockquote><pre>// ...everything the same
Lighting HalfLambert</pre>
</blockquote>
<p>Blinn-Phong, with constant exponent &#038; constant specular color, modulated by gloss map in main texture&#8217;s alpha:</p>
<blockquote><pre>Properties
    2D _MainTex
    Color _Color
    Color _SpecColor
    Float _Exponent
EndProperties
Surface
    half4 col = SAMPLE(_MainTex);
    o.Albedo = col * _Color;
    o.Specular = _SpecColor.rgb * col.a;
    o.Exponent = _Exponent;
EndSurface
Lighting BlinnPhong</pre>
</blockquote>
<p>The same Blinn-Phong, with added normal map:</p>
<blockquote><pre>Properties
    2D _MainTex
    2D _BumpMap
    Color _Color
    Color _SpecColor
    Float _Exponent
EndProperties
Surface
    half4 col = SAMPLE(_MainTex);
    o.Albedo = col * _Color;
    o.Specular = _SpecColor.rgb * col.a;
    o.Exponent = _Exponent;
    o.Normal = SAMPLE_NORMAL(_BumpMap);
EndSurface
Lighting BlinnPhong</pre>
</blockquote>
<p>I also made an illustrative-style BRDF (see <a href="http://www.valvesoftware.com/publications.html">Illustrative Rendering in Team Fortress 2</a>), but that only requires above sample to have &#8220;Lighting TF2&#8243; at the end.</p>
<p>Another thing I tried is surface that has Albedo dependent on a viewing angle, similar to <a href="http://developer.amd.com/media/gpu_assets/ShaderX2_LayeredCarPaintShader.pdf">Layered Car Paint Shader</a>. It works:</p>
<blockquote><pre>Properties
    2D _MainTex
    2D _BumpMap
    2D _SparkleTex
    Float _Sparkle
    Color _PrimaryColor
    Color _HighlightColor
EndProperties
Surface
    half4 main = SAMPLE(_MainTex);
    half3 normal  = SAMPLE_NORMAL(_BumpMap);
    half3 normalN = normalize(SAMPLE_NORMAL(_SparkleTex));
    half3 ns = normalize (normal + normalN * _Sparkle);
    half3 nss = normalize (normal + normalN);
    i.viewDir = normalize(i.viewDir);
    half nsv = max(0,dot(ns, i.viewDir));
    half3 c0 = _PrimaryColor.rgb;
    half3 c2 = _HighlightColor.rgb;
    half3 c1 = c2 * 0.5;
    half3 cs = c2 * 0.4;
    half3 tone =
        c0 * nsv +
        c1 * (nsv*nsv) +
        c2 * (nsv*nsv*nsv*nsv) +
        cs * pow(saturate(dot(nss,i.viewDir)), 32);
    main.rgb *= tone;
    o.Albedo = main;
    o.Normal = normal;
EndSurface
Lighting Lambert</pre>
</blockquote>
<p>Up next:</p>
<ul>
<li>How and where emissive terms should be placed. I cautiously omitted all emissive terms from the above examples (so my layered car shader is without reflections right now).</li>
<li>Where should things like rim lighting go? I&#8217;m not sure if it&#8217;s a surface property (increasing albedo/emission with angle) or a lighting property (a back light).</li>
</ul>
<p>My impressions so far:</p>
<ul>
<li>I like that I don&#8217;t have to write down vertex-to-fragment structures or the vertex shader. In most cases all the vertex shader does is transform stuff and pass it down to later stages, plus occasional computations that are linear over the triangle. No good reason to write it by hand.</li>
<li>I like that the above shaders do <i>not</i> deal with <i>how</i> the rendering is actually done. For Unity&#8217;s case, I&#8217;m compiling them into single pass per light forward renderer, but they <i>should</i> just work with multiple lights per pass, deferred etc. <em>Of course, that still has to be proven!</em></li>
</ul>
<p>So far so good.</p>
<p>Series index: Shaders must die, <a href="http://aras-p.info/blog/2009/05/05/shaders-must-die/">Part 1</a>, <a href="http://aras-p.info/blog/2009/05/07/shaders-must-die-part-2/">Part 2</a>, <a href="http://aras-p.info/blog/2009/05/10/shaders-must-die-part-3/"><strong>Part 3</strong></a>.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/e-ICN_U48Q8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/05/10/shaders-must-die-part-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/05/10/shaders-must-die-part-3/</feedburner:origLink></item>
		<item>
		<title>Shaders must die, part 2</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/q-em5khJZgg/</link>
		<comments>http://aras-p.info/blog/2009/05/07/shaders-must-die-part-2/#comments</comments>
		<pubDate>Thu, 07 May 2009 21:35:28 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[gpu]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=339</guid>
		<description><![CDATA[I started playing around with the idea of &#8220;shaders must die&#8220;. I&#8217;m experimenting with extracting &#8220;surface shaders&#8221; for now.
Right now my experimental pipeline is:

Write a surface shader file
Perl script transforms it into Unity 2.x shader file
Which in turn is compiled by Unity into all lighting/shadows permutations, for D3D9 and OpenGL backends. Cg is used for [...]]]></description>
			<content:encoded><![CDATA[<p>I started playing around with the idea of &#8220;<a href="http://aras-p.info/blog/2009/05/05/shaders-must-die/">shaders must die</a>&#8220;. I&#8217;m experimenting with extracting &#8220;surface shaders&#8221; for now.</p>
<p>Right now my experimental pipeline is:</p>
<ol>
<li>Write a surface shader file</li>
<li>Perl script transforms it into Unity 2.x shader file</li>
<li>Which in turn is compiled by Unity into all lighting/shadows permutations, for D3D9 and OpenGL backends. Cg is used for actual shader compilation.</li>
</ol>
<p>I have <em>very</em> simple cases working. For example: <span id="more-339"></span></p>
<blockquote><pre>Properties
    2D _MainTex
EndProperties
Surface
    o.Albedo = SAMPLE(_MainTex);
EndSurface</pre>
</blockquote>
<p>This is a &#8220;no bullshit&#8221; source code for a simple Diffuse (Lambertian) shader, 87 bytes of text.</p>
<p>The Perl script produces a Unity 2.x shader. This will be long, but bear with me &#8211; I&#8217;m trying to show how much stuff has to be written right now, when we&#8217;re operating on vertex/pixel shader level. See <a href="http://unity3d.com/support/documentation/Components/SL-Attenuation.html">Attenuation and Shadows for Pixel Lights</a> in Unity docs for how this system works.</p>
<blockquote><pre>Shader "ShaderNinja/Diffuse" {
Properties {
  _MainTex ("_MainTex", 2D) = "" {}
}
SubShader {
  Tags { "RenderType"="Opaque" }
  LOD 200
  Blend AppSrcAdd AppDstAdd
  Fog { Color [_AddFog] }
  Pass {
    Tags { "LightMode"="PixelOrNone" }
CGPROGRAM
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
struct v2f {
    float2 uv_MainTex : TEXCOORD0;
};
struct f2l {
    half4 Albedo;
};
half4 frag (v2f i) : COLOR0 {
    f2l o;
    o.Albedo = tex2D(_MainTex,i.uv_MainTex);
    return o.Albedo * _PPLAmbient * 2.0;
}
ENDCG
  }
  Pass {
    Tags { "LightMode"="Pixel" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct v2f {
    V2F_POS_FOG;
    LIGHTING_COORDS
    float2 uv_MainTex;
    float3 normal;
    float3 lightDir;
};
uniform float4 _MainTex_ST;
v2f vert (appdata_tan v) {
    v2f o;
    PositionFog( v.vertex, o.pos, o.fog );
    o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
    o.normal = v.normal;
    o.lightDir = ObjSpaceLightDir(v.vertex);
    TRANSFER_VERTEX_TO_FRAGMENT(o);
    return o;
}
uniform sampler2D _MainTex;
struct f2l {
    half4 Albedo;
    half3 Normal;
};
half4 frag (v2f i) : COLOR0 {
    f2l o;
    o.Normal = i.normal;
    o.Albedo = tex2D(_MainTex,i.uv_MainTex);
    return DiffuseLight (i.lightDir, o.Normal, o.Albedo, LIGHT_ATTENUATION(i));
}
ENDCG
  }
}
Fallback "VertexLit"
}</pre>
</blockquote>
<p>Phew, that is quite some typing to get simple diffuse shader (1607 bytes)! Well, at least all the lighting/shadow combinations are handled by Unity macros here. When Unity takes this shader and compiles into all permutations, it results in 58 kilobytes of shader assembly (D3D9 + OpenGL, 17 light/shadow combinations).</p>
<p>Let&#8217;s try something slightly different: bumpmapped, with a detail texture:</p>
<blockquote><pre>Properties
    2D _MainTex
    2D _Detail
    2D _BumpMap
EndProperties
Surface
    o.Albedo = SAMPLE(_MainTex) * SAMPLE(_Detail) * 2.0;
    o.Normal = SAMPLE_NORMAL(_BumpMap);
EndSurface
</pre>
</blockquote>
<p>This is 173 bytes of text. Generated Unity shader is 2098 bytes, which compiles into 74 kilobytes of shader assembly.</p>
<p>In this case, the processing script detects that surface shader modifies normal per pixel, and does the necessary tangent space light transformations. It all just works!</p>
<p>So this is where I am now. Next up: detect which lighting model to use based on surface parameters (right now it always uses Lambertian). Fun!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/q-em5khJZgg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/05/07/shaders-must-die-part-2/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/05/07/shaders-must-die-part-2/</feedburner:origLink></item>
		<item>
		<title>Shaders must die</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/Gy050D8ZoWw/</link>
		<comments>http://aras-p.info/blog/2009/05/05/shaders-must-die/#comments</comments>
		<pubDate>Tue, 05 May 2009 12:59:48 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[gpu]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[rendering]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=324</guid>
		<description><![CDATA[It came in as a simple thought, and now I can&#8217;t shake it off. So I say:

Ok, now that the controversial bits are done, let&#8217;s continue.

Most of this can be (and probably is) wrong, and I haven&#8217;t given it enough thought yet. But here&#8217;s my thinking about shaders of &#8220;regular scene objects&#8221;. All of below [...]]]></description>
			<content:encoded><![CDATA[<p>It came in as a simple <a href="http://twitter.com/aras_p/status/1651784380">thought</a>, and now I can&#8217;t shake it off. So I say:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/05/shadersmustdie.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/05/shadersmustdie.jpg" alt="Shaders Must Die" title="Shaders Must Die" width="550" height="550" class="alignnone size-full wp-image-325" /></a></p>
<p>Ok, now that the controversial bits are done, let&#8217;s continue.</p>
<p><span id="more-324"></span><br />
Most of this can be (and probably is) wrong, and I haven&#8217;t given it enough thought yet. But here&#8217;s my thinking about shaders of &#8220;regular scene objects&#8221;. All of below is about things that need to interact with lighting; I&#8217;m not talking about shaders for postprocessing, one-off uses, special effects, GPGPU or kitchen sinks.</p>
<p><strong>Operating on vertex/pixel shader level is a wrong abstraction level</strong></p>
<p>Instead, it should be separated out into &#8220;<em>surface shader</em>&#8221; (albedo, normal, specularity, &#8230;), &#8220;<em>lighting model</em>&#8221; (Lambertian, Blinn Phong, &#8230;) and &#8220;<em>light shader</em>&#8221; (attenuation, cookies, shadows).</p>
<ul>
<li>Probably 90% of the cases would only touch the surface shader (mostly mix textures/colors in various ways), and choose from some precooked lighting models.</li>
<li>9% of the cases would tweak the lighting model. Most of the things would settle for &#8220;standard&#8221; (Blinn-Phong or similar), with some stuff using skin or anisotropic or &#8230;</li>
<li>The &#8220;light shader&#8221; only needs to be touched once in a blue moon by ninjas. Once the shadowing and attenuation systems are implemented, there&#8217;s almost no reason for shader authors to see all the dirty bits.</li>
</ul>
<p>Yes, current hardware operates on vertex/geometry/pixel shaders, which is a logical thing to do for hardware. After all, these are the primitives it works on when rendering. But those primitives are <em>not</em> the things you work on when authoring how a surface should look or how it should react to a light.</p>
<p><strong>Simple code; no redundant info; sensible defaults</strong></p>
<p>In the ideal world, here&#8217;s a simple surface shader (the syntax is deliberately stupid):</p>
<blockquote><p>
Haz Texture;<br />
Albedo = sample Texture;
</p></blockquote>
<p>Or with bump mapping added:</p>
<blockquote><p>
Haz Texture;<br />
Haz NormalMap;<br />
Albedo = sample Texture;<br />
Normal = sample_normal NormalMap;
</p></blockquote>
<p>And this should be <em>all</em> the info you have to provide. This would choose the lighting model based on used things (in this case, Lambertian). It would <em>somehow</em> just work with all kinds of lights, shadows, ambient occlusion and whatnot.</p>
<p>Compare to how much has to be written to implement a simple surface in your current shader technology, so that it would work &#8220;with everything&#8221;.</p>
<p>From the above shader, proper hardware shaders can be generated for DX9, DX11, DX1337, OpenGL, next-gen and next-next-gen consoles, mobile platforms with capable hardware, etc.</p>
<p>It can be used in accumulative forward rendering, forward rendering with multiple lights per pass, hybrid (light pre-pass / prelight) rendering, deferred rendering etc. Heck, even for a raytracer if you have one at hand.</p>
<p>I want!</p>
<p>Now of course, it won&#8217;t be as nice as more complex materials have to be expressed. Some might not even be possible. But shader text complexity should grow with material complexity; and all information that is redundant, implied, inferred or useless should be eliminated. <em>There&#8217;s no good reason to stick to conventions and limits of current hardware just because it operates like that</em>.</p>
<p>Shaders must die!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/Gy050D8ZoWw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/05/05/shaders-must-die/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/05/05/shaders-must-die/</feedburner:origLink></item>
		<item>
		<title>Google O3D – it’s going to be interesting</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/nEOya5XBfDo/</link>
		<comments>http://aras-p.info/blog/2009/05/05/google-o3d-its-going-to-be-interesting/#comments</comments>
		<pubDate>Tue, 05 May 2009 12:01:24 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[rendering]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=317</guid>
		<description><![CDATA[A couple of weeks ago Google announced O3D: an open source web browser plugin for low level accelerated 3D graphics. The website for O3D project is here.
Of course this created some buzz (hey, it&#8217;s Google after all). And it is in some way a competing technology with Unity. I think it&#8217;s going to be interesting, [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago Google <a href="http://google-code-updates.blogspot.com/2009/04/toward-open-web-standard-for-3d.html">announced O3D</a>: an open source web browser plugin for low level accelerated 3D graphics. The website for O3D project <a href="http://code.google.com/apis/o3d/">is here</a>.</p>
<p>Of course this created some buzz (hey, it&#8217;s Google after all). And it is in some way a competing technology with <a href="http://unity3d.com/">Unity</a>. I think it&#8217;s going to be interesting, so I say &#8220;welcome competition!&#8221;</p>
<p><em>Preemptive blah blah: this website is my personal opinion and does not represent the views of my employer, former employers or anyone else other than myself.</em></p>
<p>Unity is one of the players in &#8220;3D on the web&#8221; space. 3D graphics in the browser are in fact nothing new. <a href="http://unity3d.com/unity-web-player-2.x">Unity&#8217;s browser plugin</a> has existed since 2005 and is now in eight digits installations count. There is <a href="http://en.wikipedia.org/wiki/VRML">VRML</a>, <a href="http://en.wikipedia.org/wiki/X3D">X3D</a>, <a href="http://en.wikipedia.org/wiki/Adobe_Shockwave">Adobe Shockwave</a>, <a href="http://en.wikipedia.org/wiki/Virtools">3DVIA/Virtools</a>, software rendering approaches on top of <a href="http://en.wikipedia.org/wiki/3D_Flash">Flash</a> and so on.</p>
<p>In my view, major advantages that Unity has compared to O3D:</p>
<ul>
<li>It&#8217;s not only about the graphics. Unity has physics, audio, input, scripting, streaming, networking, asset pipeline and whatnot. O3D is only about the graphics, and at a lower level.</li>
<li>Unity runs on wider range of hardware. O3D requires Shader Mode 2.0 or later hardware, so about 30% of the &#8220;machines on the internet&#8221; can&#8217;t run O3D (based on our <a href="http://unity3d.com/webplayer/hwstats/pages/web-2009Q1-shadergen.html">2009Q1 data</a>). Couple that with lots of compatibility workarounds that we have and it&#8217;s probably safe to say that Unity is more <em>stable and mature</em> at this point.</li>
<li>Unity is not only about the web. There&#8217;s support for iPhone, Nintendo Wii, standalone games, and with time more console and mobile platforms will come.</li>
<li>Creating and improving Unity is our primary and only focus as a company. In Google&#8217;s case, O3D is just another technology in their vast portfolio.</li>
</ul>
<p><em>Of course</em>, O3D also has advantages:</p>
<ul>
<li>It&#8217;s done by Google! When Google does <del datetime="2009-04-24T12:06:53+00:00">something</del> anything, people notice immediately :)</li>
<li>O3D is free and open source. Hard to beat the free price, and open source does have it&#8217;s benefits. O3D is not a &#8220;standard&#8221; of any sort right now, but it looks like Google would want it to become one.</li>
<li>Only focusing on low level graphics has it&#8217;s benefits: it&#8217;s lightweight, it appeals to hackers and graphics programmers who want to be in control. Unity&#8217;s higher level is much easier and faster to use, but low level hacking can be fun.</li>
</ul>
<p>Of course there are tons of other differences (I might have missed something important as well).</p>
<p>For me as a rendering guy, it&#8217;s interesting to see O3D taking similar decisions here and there (e.g. they don&#8217;t use GLSL on OpenGL either because it does not really work in the real world).</p>
<p>So&#8230; we&#8217;ll see where things will go. It&#8217;s going to be interesting!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/nEOya5XBfDo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/05/05/google-o3d-its-going-to-be-interesting/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/05/05/google-o3d-its-going-to-be-interesting/</feedburner:origLink></item>
		<item>
		<title>All games in one short paragraph</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/Yl5udoHuYTY/</link>
		<comments>http://aras-p.info/blog/2009/04/03/all-games-in-one-short-paragraph/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 05:36:28 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[games]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=314</guid>
		<description><![CDATA[Here, ryg nails it:
why would you want sound and physics when you can have sparsely clothed ninja space marine amazon secret agents riding on chainsaw-hoofed flying pink stealth space unicorns through a brightly colored dystopian african urban jungle fantasy wasteland island state populated with mutated propaganda-spewing gas mask-wearing alien nazi zombie demons that entered this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pouet.net/topic.php?which=6210&#038;page=4">Here</a>, ryg nails it:</p>
<blockquote><p>why would you want sound and physics when you can have sparsely clothed ninja space marine amazon secret agents riding on chainsaw-hoofed flying pink stealth space unicorns through a brightly colored dystopian african urban jungle fantasy wasteland island state populated with mutated propaganda-spewing gas mask-wearing alien nazi zombie demons that entered this island planet dimension through a hellgate portal invasion triggered by a black magic freak teleportation experiment resonance cascade accident caused by a power-hungry mad scientist wizard evil genius working for a multinational corporation conspiracy of lawyers and weapons manufacturers without morals, and all that in its proper realtime dynamically lit globally illuminated deferred-shaded parallax-occlusion-mapped ambient-occluded shadow-buffered high dynamic range silky smooth glory?</p></blockquote>
<p>Pretty much sums up the mainstream game industry!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/Yl5udoHuYTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/04/03/all-games-in-one-short-paragraph/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/04/03/all-games-in-one-short-paragraph/</feedburner:origLink></item>
		<item>
		<title>Unity 2.5 is out</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/WpoqJ2F3ljg/</link>
		<comments>http://aras-p.info/blog/2009/03/19/unity-25-is-out/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 13:13:48 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=304</guid>
		<description><![CDATA[Unity 2.5 is finally released. In summary:

Here&#8217;s what&#8217;s new. Here&#8217;s the download page.
My 11th Unity release since I joined 3+ years ago. This is quite a crazy release that involved almost complete editor tools rewrite and lots of other juggling. Was not exactly a walk in the park, but it&#8217;s done now. Meet me at [...]]]></description>
			<content:encoded><![CDATA[<p>Unity 2.5 is finally released. In summary:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/03/unity25.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/unity25-500x241.jpg" alt="Unity 2.5" title="Unity 2.5" width="500" height="241" class="alignnone size-medium wp-image-305" /></a></p>
<p>Here&#8217;s <a href="http://unity3d.com/unity/whats-new/unity-2.5">what&#8217;s new</a>. Here&#8217;s the <a href="http://unity3d.com/unity/download">download page</a>.</p>
<p>My 11th Unity release since I joined <a href="http://aras-p.info/blog/2006/01/10/switched-jobs-almost-back-in-this-crazy-industry/">3+ years ago</a>. This is quite a crazy release that involved <em>almost complete</em> editor tools rewrite and lots of other juggling. Was not exactly a walk in the park, but it&#8217;s done now. Meet me at <a href="http://www.gdconf.com/">GDC in San Francisco</a> next week and I&#8217;ll tell you the war stories (Unity booth is 5110 NH).</p>
<p>Here&#8217;s the obligatory source code commits graph:<br />
<a href="http://aras-p.info/blog/wp-content/uploads/2009/03/25commits.png"><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/25commits-500x170.png" alt="2.5 svn commits" title="2.5 svn commits" width="500" height="170" class="alignnone size-medium wp-image-308" /></a><br />
18 people involved in source code, 5315 commits, 18501 file changes. Of course, svn commits do not <em>mean</em> anything&#8230; I&#8217;m just fascinated by graphs and numbers.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/WpoqJ2F3ljg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/03/19/unity-25-is-out/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/03/19/unity-25-is-out/</feedburner:origLink></item>
		<item>
		<title>Another Vista review (after 6 months of usage)</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/9U3uZgiQawI/</link>
		<comments>http://aras-p.info/blog/2009/03/18/another-vista-review-after-6-months-of-usage/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:16:37 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=294</guid>
		<description><![CDATA[Ok, I don&#8217;t exactly like Windows Vista. But I just spent 6 months using Vista as my primary OS at work&#8230; because everyone else was using XP, and someone had to make sure everything works on Vista as well. So it was me.
In summary, Vista is not that bad.
Once you get used to changes in [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I <a href="http://aras-p.info/blog/2008/06/03/the-problem-with-vista/">don&#8217;t exactly like Windows Vista</a>. But I just spent 6 months using Vista as my primary OS at work&#8230; because everyone else was using XP, and <em>someone</em> had to make sure everything works on Vista as well. So it was me.</p>
<p>In summary, Vista is not <em>that bad</em>.</p>
<p>Once you get used to changes in Explorer, different skin and so on &#8211; it&#8217;s actually usable. I think they have made some real improvements in the underlying technology, too bad they managed to &#8220;compensate&#8221; for all of that by inconsistencies and lack of polish in user interface.</p>
<p>At this point it&#8217;s minor quirks in UI that annoy me, but apart from that, Vista is okay. Look:</p>
<p><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/vista-iconoverlay.png" alt="Icon overlay blending" title="Icon overlay blending" width="144" height="152" class="alignnone size-full wp-image-295" /><br />
Who implemented blending of icon overlays and do they still have a job? No sir, that shield icon is <em>not</em> properly blended here!</p>
<p><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/vista-burn.png" alt="Burn icon" title="Burn icon" width="323" height="132" class="alignnone size-full wp-image-296" /><br />
Who thought it&#8217;s a good idea to make the Burn icon bright red? In 6 months, I <em>never</em> used it. Why is it the brightest thing in the whole Explorer window?</p>
<p><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/vista-upfolder.png" alt="Up one folder" title="Up one folder" width="366" height="143" class="alignnone size-full wp-image-297" /><br />
Try going one folder up without resorting to this drop down menu. Utilities is the <em>current</em> folder here. <del datetime="2009-03-18T12:52:27+00:00">And no, there&#8217;s no keyboard shortcut for &#8220;go up&#8221; either (there was in XP, which was perfect)</del>.</p>
<p><img src="http://aras-p.info/blog/wp-content/uploads/2009/03/vista-shutdown.png" alt="Shutdown awesome" title="Shutdown awesome" width="283" height="158" class="alignnone size-full wp-image-298" /><br />
And of course, the awesome shutdown menu. The two buttons &#8211; <em>never</em> used them. What I always use is &#8220;Shut Down&#8221; from the menu. And let&#8217;s not even talk about all the choices in the menu (no, more choices is not always better).</p>
<p>So yeah. It&#8217;s not stellar, it has tons of small annoyances (and some large ones &#8211; try developing web plugins with UAC on&#8230;), but it&#8217;s usable. I might have gotten used to it by now, actually.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/9U3uZgiQawI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/03/18/another-vista-review-after-6-months-of-usage/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/03/18/another-vista-review-after-6-months-of-usage/</feedburner:origLink></item>
		<item>
		<title>How view on C++ changes over time</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/4ZAkyU5T-KU/</link>
		<comments>http://aras-p.info/blog/2009/03/01/how-view-on-c-changes-over-time/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 17:23:40 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=287</guid>
		<description><![CDATA[It&#8217;s funny how one&#8217;s view on things change over time.
Back in 2002, I wrote something that would be roughly translated like &#8220;C++ amazes me more and more&#8221;. In a positive sense! And I was talking about what is Boost.Spirit now.
A reply on local game development forums I wrote today (again, rough translation): &#8220;C++ is very [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s funny how one&#8217;s view on things change over time.</p>
<p>Back in 2002, I <a href="http://aras-p.info/relyzai00.html">wrote</a> something that would be roughly translated like &#8220;C++ amazes me more and more&#8221;. In a positive sense! And I was talking about what is <a href="http://spirit.sourceforge.net/">Boost.Spirit</a> now.</p>
<p>A <a href="http://www.gamedev.lt/viewtopic.php?p=19644#p19644">reply</a> on local game development forums I wrote today (again, rough translation): &#8220;C++ is very hard and quite a horrible language, maybe you should not use it unless there are no alternatives&#8221;.</p>
<p>That&#8217;s quite a change in attitude we have here!</p>
<p>I feel like much of C++ horrors are a consequence of &#8220;it just somehow happened&#8221; (the whole template metaprogramming thing) or as a backwards compatibility with C requirement. Or maybe not, but I do agree with what <a href="https://mollyrocket.com/forums/viewtopic.php?p=1955#1955">ryg says here</a>. Let&#8217;s play the internet memes:<br />
<img src="http://aras-p.info/blog/wp-content/uploads/2009/03/cppaccident.jpg" alt="C++ Accident" title="cppaccident" width="513" height="437" class="alignnone size-full wp-image-291" /></p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/4ZAkyU5T-KU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/03/01/how-view-on-c-changes-over-time/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/03/01/how-view-on-c-changes-over-time/</feedburner:origLink></item>
		<item>
		<title>LTGameJam 2009 postmortem</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/kfb5cEpijhQ/</link>
		<comments>http://aras-p.info/blog/2009/02/20/ltgamejam-2009-postmortem/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 19:18:13 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=279</guid>
		<description><![CDATA[So LTGameJam 2009 is over. I&#8217;ve been there as part organizer, part participant, so my views are both biased and incomplete (being an organizer means you have to run around a bit, instead of just focusing on making the game).
The theme for the games was &#8220;as long as we have each other, we will never [...]]]></description>
			<content:encoded><![CDATA[<p>So <a href="http://ltgamejam.org/2009/">LTGameJam 2009</a> is over. I&#8217;ve been there as part organizer, part participant, so my views are both biased and incomplete (being an organizer means you have to run around a bit, instead of just focusing on making the game).</p>
<p>The theme for the games was &#8220;as long as we have each other, we will never run out of problems&#8221;. Additionally, games had to be short (5 minutes of play or less), and somehow incorporate one of &#8220;affectionate&#8221;, &#8220;patriotic&#8221; or &#8220;missing&#8221; words.</p>
<p><a href="http://ltgamejam.org/2009/games.html#missingpeace"><img src="http://aras-p.info/blog/wp-content/uploads/2009/02/missingpeace-150x150.jpg" alt="missingpeace" title="missingpeace" width="150" height="150" class="alignright size-thumbnail wp-image-282" /></a>I worked on a <a href="http://ltgamejam.org/2009/games.html#missingpeace">Missing Peace</a> game. It&#8217;s nothing really fancy, does not quite follow the idea and incorporates the above mentioned words in a cheap way (&#8221;just stick it into a title! haha!&#8221;). It was probably the most polished game from all games made there though (for some definition of polish)&#8230; too bad it&#8217;s not actually fun to play :) </p>
<p>Oh well. I just did not have any interesting ideas, and wasn&#8217;t particularly inspired, so there is the result. Probably burnout of trying to finish <a href="http://unity3d.com/unity/coming-soon/unity-2.5.html">Unity 2.5</a> at work had it&#8217;s toll as well.</p>
<p>Overall, the good parts about this game jam:</p>
<ul>
<li>It was fun (hey, that&#8217;s the whole idea)</li>
<li>Some very positive progress, compared to LTGameJams <a href="http://ltgamejam.org/2002/">2002</a>/<a href="http://ltgamejam.org/2003/">2003</a>: more people (20-25, up from 10-15), much better proportion of artists (about 30%, up from almost zero), more people who don&#8217;t know each other, more games made by folks outside of <a href="http://nesnausk.org/">nesnausk!</a> group :)</li>
<li>Some of the ideas that were brainstormed have interesting bits.</li>
<li>Did I mention it was fun?</li>
</ul>
<p>On the downside, I get the feeling that the games made this time were <em>not crazy enough</em>. GameJams are meant to generate totally whacky, crazy and amazing ideas; however this time most of the games were known game mechanics, pretty safe idea and so on. Have to improve on that the next time.</p>
<p>So that&#8217;s about it!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/kfb5cEpijhQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/02/20/ltgamejam-2009-postmortem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/02/20/ltgamejam-2009-postmortem/</feedburner:origLink></item>
		<item>
		<title>Off to game jam</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/IWQ6rHPmYWo/</link>
		<comments>http://aras-p.info/blog/2009/01/30/off-to-game-jam/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 09:59:31 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=277</guid>
		<description><![CDATA[Off to local Global Game Jam!
]]></description>
			<content:encoded><![CDATA[<p>Off to <a href="http://ltgamejam.org/2009/">local Global Game Jam</a>!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/IWQ6rHPmYWo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/01/30/off-to-game-jam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/01/30/off-to-game-jam/</feedburner:origLink></item>
		<item>
		<title>Twitter! Twitter!</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/c8YDVZxInEw/</link>
		<comments>http://aras-p.info/blog/2009/01/26/twitter-twitter/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 14:25:42 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=273</guid>
		<description><![CDATA[Ok, I&#8217;m somewhat late to jump onto the latest fads bandwagon, but here it goes &#8211; I added a Twitter widget here on the sidebar. I blame Steve Streeting for pushing me over the edge!
Me on Twitter.
]]></description>
			<content:encoded><![CDATA[<p>Ok, I&#8217;m <a href="http://www.gapingvoid.com/Moveable_Type/archives/003881.html">somewhat late</a> to jump onto the latest fads bandwagon, but here it goes &#8211; I added a Twitter widget here on the sidebar. I blame <a href="http://www.stevestreeting.com/2009/01/22/tweeting-about-ogre-dev/">Steve Streeting</a> for pushing me over the edge!</p>
<p><a href="http://twitter.com/aras_p">Me on Twitter</a>.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/c8YDVZxInEw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/01/26/twitter-twitter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/01/26/twitter-twitter/</feedburner:origLink></item>
		<item>
		<title>Fixed function lighting in vertex shader – how?</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/Ng5BgRdmnKI/</link>
		<comments>http://aras-p.info/blog/2009/01/22/fixed-function-lighting-in-vertex-shader-how/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 20:32:49 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[d3d]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=261</guid>
		<description><![CDATA[Sometime soon I&#8217;ll have to implement fixed function lighting pipeline in vertex shaders. Why? Because mixing fixed function and vertex shaders in multiple passes does not guarantee identical transformation results, thus requiring depth bias or projection matrix tweaks, which leads to various artifacts that annoy people to hell.
I don&#8217;t really know why that happens, because [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime soon I&#8217;ll have to implement fixed function lighting pipeline in vertex shaders. Why? Because mixing fixed function and vertex shaders in multiple passes does not guarantee identical transformation results, thus requiring depth bias or projection matrix tweaks, which leads to <a href="http://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/">various artifacts</a> that annoy people to hell.</p>
<p>I don&#8217;t really know <em>why</em> that happens, because it seems that most modern cards don&#8217;t have fixed function units, so internally they are running shaders anyway. DX9 runtime on Vista&#8217;s WDDM also seems to be only handling shaders to the driver internally. Still, for some reason somewhere the precision does not match&#8230;</p>
<p>How such a task should be approached?</p>
<p>My requirements are:</p>
<ul>
<li>Should handle any possible state combination in D3D fixed function T&#038;L.</li>
<li>D3D 9.0c, using vertex shader 2.0 is ok. For now I don&#8217;t care about OpenGL.</li>
<li>No HLSL at runtime. I don&#8217;t want to add a megabyte or more to Unity web player just for HLSL. DX9 shader assembly is ok, because we already have the assembler code.</li>
<li>Should work as fast (or close to) as the regular fixed function pipeline.</li>
</ul>
<p>I looked at ATI&#8217;s <a href="http://developer.amd.com/samples/FixedFuncShader/Pages/default.aspx">FixedFuncShader sample</a>. It&#8217;s an <strong>ubershader approach</strong>; one large (230 instructions or so) shader with static VS2.0 branching. It had some obvious places to optimize, I could get it down to 190 or so instructions, kill some <a href="http://msdn.microsoft.com/en-us/library/bb147316(VS.85).aspx">rcp</a>&#8217;s and reduce the amount of constant storage by 2x.</p>
<p>Still, it did not handle some things in the D3D T&#038;L or had some issues:</p>
<ul>
<li>It assumes one input UV, one output UV and no texture matrices. This place in T&#038;L gets quite convoluted &#8211; any input UVs or a texgen mode can be transformed by matrices of various sizes, and routed into any output UVs.</li>
<li>It was not using full T&#038;L lighting model. No biggie here.</li>
<li>I haven&#8217;t checked with NVShaderPerf or AMD ShaderAnalyzer yet, but last time I checked the static branch instruction was taking two clocks on some NV architecture. So ubershader approach does not come for free.</li>
</ul>
<p>Another thing I&#8217;m considering, is to combine final shader(s) from <strong>assembly fragments</strong>, with some simple register allocation.</p>
<p>In T&#038;L shader code, there&#8217;s only limited set of could-be-redundant computations, mostly computing world space position, camera space normal, view vector and so on (those could be used lighting, texgen or fog). Those computations can be explicitly put into separate fragments, and later fragments could just use their result.</p>
<p>What is left then is some register allocation. A shader assembly fragment could want some temporary registers for internal use (this is simple, just give it a bunch of unused registers), also want some registers as input (from previous fragments), and save some output in registers.</p>
<p>Again, I haven&#8217;t checked with shader performance tools, but I <em>think, guess and hope</em> that the drivers do additional register allocation, liveness analysis etc. when converting D3D shader bytecode into hardware format. This would mean that <em>I</em> can be quite sloppy with it, i.e. don&#8217;t have to implement some super smart allocation scheme.</p>
<p>I wrote some experimental code for the shader assembly combiner and so far it looks like a reasonable approach (and not too hard either).</p>
<p>Does that make sense? Or did everyone solve those problems eons ago already?</p>
<p><strong>Edit</strong>: half a year later, I wrote a technical report on how I implemented all this: <a href="http://aras-p.info/texts/VertexShaderTnL.html">http://aras-p.info/texts/VertexShaderTnL.html</a></p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/Ng5BgRdmnKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/01/22/fixed-function-lighting-in-vertex-shader-how/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/01/22/fixed-function-lighting-in-vertex-shader-how/</feedburner:origLink></item>
		<item>
		<title>Quote of the day</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/4TdDxvQMCiM/</link>
		<comments>http://aras-p.info/blog/2009/01/05/quote-of-the-day/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 12:12:28 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=255</guid>
		<description><![CDATA[Somewhat amusing quote from gamedeff.com:
Дешевая популярность в тяжелые времена не мешает, поэтому в блог срать надо почаще (всем, кстати, рекомендую).
Preemptive note: Google Translate does not quite cope with it.
]]></description>
			<content:encoded><![CDATA[<p>Somewhat amusing quote from <a href="http://blog.gamedeff.com/?p=180">gamedeff.com</a>:</p>
<blockquote><p>Дешевая популярность в тяжелые времена не мешает, поэтому в блог срать надо почаще (всем, кстати, рекомендую).</p></blockquote>
<p>Preemptive note: Google Translate does not quite cope with it.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/4TdDxvQMCiM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2009/01/05/quote-of-the-day/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2009/01/05/quote-of-the-day/</feedburner:origLink></item>
		<item>
		<title>ARB_draw_buffers</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/kHClHzT6KbA/</link>
		<comments>http://aras-p.info/blog/2008/12/30/arb-draw-buffers/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 07:48:09 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[opengl]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=250</guid>
		<description><![CDATA[
No, I don&#8217;t have any particular point to make. But I did not even get the t-shirt&#8230;
]]></description>
			<content:encoded><![CDATA[<p><img src="http://aras-p.info/blog/wp-content/uploads/2008/12/arb_draw_buffers.jpg" alt="ARB_draw_buffers" title="ARB_draw_buffers" width="600" height="455" class="alignnone size-full wp-image-249" /></p>
<p>No, I don&#8217;t have any particular point to make. But I did not even get the t-shirt&#8230;</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/kHClHzT6KbA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/12/30/arb-draw-buffers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/12/30/arb-draw-buffers/</feedburner:origLink></item>
		<item>
		<title>Achievement of the week: MakeVistaDWMHappyDance</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/JZsXoYCFlrg/</link>
		<comments>http://aras-p.info/blog/2008/12/11/achievement-of-the-week-makevistadwmhappydance/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:16:05 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=247</guid>
		<description><![CDATA[This was the function that I added:
void GUIView::MakeVistaDWMHappyDance()
{
    // Looks like Vista has some bug in DWM. Whenever we maximize or dock
    // a view, we must do something magic, otherwise
    // white stuff appears in place of the view.
    // See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4208117&#038;SiteID=1

 [...]]]></description>
			<content:encoded><![CDATA[<p>This was the function that I added:</p>
<blockquote><pre>void GUIView::<strong>MakeVistaDWMHappyDance</strong>()
{
    // Looks like Vista has some bug in DWM. Whenever we maximize or dock
    // a view, we must do something magic, otherwise
    // white stuff appears in place of the view.
    // See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4208117&#038;SiteID=1

    bool earlierThanVista = systeminfo::GetOperatingSystemNumeric() &lt; 600;
    if( earlierThanVista )
        return;

    // What seems to work is drawing one pixel via GDI.
    // We draw it at (1,1) with usual background color.
    int grayColor = 0.61f * 255.0f;
    PAINTSTRUCT ps;
    BeginPaint(m_View, &#038;ps);
    SetPixel(ps.hdc, 1, 1, RGB(grayColor,grayColor,grayColor));
    EndPaint(m_View, &#038;ps);
}</pre>
</blockquote>
<p>I know. Reading from screen when Aero is on is slow, bad and wrong. But then, what do you do? It&#8217;s better than users staring an all-white window just because Vista decided to draw it white, no matter what you think you&#8217;re drawing into it.</p>
<p>&#8230;still, <code>MakeVistaDWMHappyDance</code> is not nearly as cool as </p>
<blockquote><p>internal interface ICanHazCustomMenu { &#8230; }</p></blockquote>
<p> that Nicholas added a while ago.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/JZsXoYCFlrg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/12/11/achievement-of-the-week-makevistadwmhappydance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/12/11/achievement-of-the-week-makevistadwmhappydance/</feedburner:origLink></item>
		<item>
		<title>Don’t try to outsmart the compiler</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/ClCUN32fUCA/</link>
		<comments>http://aras-p.info/blog/2008/12/06/dont-try-to-outsmart-the-compiler/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 21:58:04 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=245</guid>
		<description><![CDATA[The other day at work there was a need to flip an image vertically, in a way that did not bring large portions of other code that deals with images. Flipping vertically is easy:
for( int y = 0; y < height/2; ++y ) {
    memswap( img+y*width, img+(height-y-1)*width, width*img(arr[0]) );
}

memswap function was done [...]]]></description>
			<content:encoded><![CDATA[<p>The other day at work there was a need to flip an image vertically, in a way that did not bring large portions of other code that deals with images. Flipping vertically is easy:</p>
<blockquote><pre>for( int y = 0; y < height/2; ++y ) {
    memswap( img+y*width, img+(height-y-1)*width, width*img(arr[0]) );
}</pre>
</blockquote>
<p>memswap function was done this way:</p>
<blockquote><pre>// why isnt this in the std lib?
// using XOR to avoid tmp var
void memswap( void* m1, void* m2, size_t n )
{
    char *p = (char*)m1; char *q = (char*)m2;
    while ( n-- ) {
        *p ^= *q; *q ^= *p; *p ^= *q;
        p++; q++;
    }
}</pre>
</blockquote>
<p>The comment above the function was what triggered my interest. I just added:</p>
<blockquote><p>
// because it can be slower (local variable is likely in register;<br />
// whereas using XOR involves reads/writes to memory)
</p></blockquote>
<p>But then I got interested in this, I just <em>had to</em> check what happens in one or another case.</p>
<p>Using Apple's gcc 4.0.1 on Core 2 Duo, the above memory swapping code takes about 12.5 clock cycles per swapped image pixel (pixel = 4 bytes). The inner loop is this:</p>
<blockquote><pre>movzx  eax,BYTE PTR [edx-0x1]
xor    al,BYTE PTR [ecx-0x1]
mov    BYTE PTR [edx-0x1],al
xor    al,BYTE PTR [ecx-0x1]
mov    BYTE PTR [ecx-0x1],al
xor    BYTE PTR [edx-0x1],al
dec    ebx
inc    edx
inc    ecx
cmp    ebx,0xffffffff
jne    loopstart</pre>
</blockquote>
<p>So the loop is three memory reads, three writes and some increments of the pointers / loop counter. Visual C++ 2008 compiles it very similarly, just uses more complex addressing mode to save one loop counter:</p>
<blockquote><pre>movzx       edx,byte ptr [ecx+eax]
xor         byte ptr [eax],dl
mov         dl,byte ptr [eax]
xor         byte ptr [ecx+eax],dl
mov         dl,byte ptr [ecx+eax]
xor         byte ptr [eax],dl
dec         esi
inc         eax
test        esi,esi
jne         loopstart</pre>
</blockquote>
<p>What if we don't do this "XOR trick", and just swap the contents using a temporary variable?</p>
<blockquote><pre>
// ...
char t = *p; *p = *q; *q = t;
// ...
</pre>
</blockquote>
<p>Lo and behold, now it runs at 7 cycles / pixel (almost twice as fast), and the inner loop is two memory reads and two writes:</p>
<blockquote><pre>
movzx  edx,BYTE PTR [ebx-0x1]
movzx  eax,BYTE PTR [ecx-0x1]
mov    BYTE PTR [ebx-0x1],al
mov    BYTE PTR [ecx-0x1],dl
// ... incrementing pointers / counter here, like in previous case
</pre>
</blockquote>
<p>So yeah. The XOR trick is pretty much useless here - it's twice as slow. Hey, it can even be slower as images get larger - if tested on a 2048x2048 image, regular swap still takes 7 cycles/pixel, but XOR trick takes 55 cycles/pixel!</p>
<p>I guess XOR trick is useful only in quite rare situations, for example when you're inside of some inner loop and want to swap register values without spilling them to memory or using an additional register. Heh, <a href="http://en.wikipedia.org/wiki/XOR_swap_algorithm">Wikipedia has info on this</a>, so I'm not saying anything new :)</p>
<p>Now of course, if we happen to know that our pixels are 32 bits in size, there's no good reason to keep the loop in bytes. We can operate on integers instead:</p>
<blockquote><pre>
void memswapI( void* m1, void* m2, size_t n )
{
    size_t nn = n/sizeof(int);
    int *p = (int*)m1; int *q = (int*)m2;
    while ( nn-- ) {
        int t = *p; *p = *q; *q = t;
        p++; q++;
    }
}</pre>
</blockquote>
<p>This runs at 1.5 cycles/pixel (XOR variant at 2.5 cycles/pixel). The assembly is pretty much the same, just with 32 bit registers.</p>
<p>Another option? If you use STL, just use:</p>
<blockquote><pre>std::swap_ranges(p, p+n, q);</pre>
</blockquote>
<p>on the pixel datatype. On 32 bit pixels, this also runs at 1.5 cycles/pixel.</p>
<p>So yeah. Don't try to outsmart the compiler without measuring it.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/ClCUN32fUCA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/12/06/dont-try-to-outsmart-the-compiler/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/12/06/dont-try-to-outsmart-the-compiler/</feedburner:origLink></item>
		<item>
		<title>Cool tech vs. boring details</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/M5DmHTBqd1g/</link>
		<comments>http://aras-p.info/blog/2008/11/22/cool-tech-vs-boring-details/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 19:24:37 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=243</guid>
		<description><![CDATA[Some of the stuff I&#8217;ve been working on last week:

Fixed import progress bar for movies with no audio
Fixed first context menu click not working on Windows
Eye dropper backend on Windows
Export Package actually works on Windows
Compare Binary works on Windows
Add checkbox to project wizard to always open it on startup
F1 in bundled text editor goes to [...]]]></description>
			<content:encoded><![CDATA[<p>Some of the stuff I&#8217;ve been working on last week:</p>
<ul>
<li>Fixed import progress bar for movies with no audio</li>
<li>Fixed first context menu click not working on Windows</li>
<li>Eye dropper backend on Windows</li>
<li>Export Package actually works on Windows</li>
<li>Compare Binary works on Windows</li>
<li>Add checkbox to project wizard to always open it on startup</li>
<li>F1 in bundled text editor goes to scripting docs for current word</li>
<li>Fixed q/w/e/r keys in password fields and text areas toggling active Tool on Windows</li>
<li>Fixed panes not repainting on Windows after some change is done via context menu on them</li>
<li>&#8230;and so on.</li>
</ul>
<p><em>Boring tiny little details.</em></p>
<p>This probably best summarizes where lion&#8217;s share of time goes when developing anything. I&#8217;m not working on some cool spherical harmonics lightmap compression. Or on cunning ways to encode shadow map information for better filtering. Or on using CUDA to compute something interesting.</p>
<p>In other words, I&#8217;m not working on cool technology. Instead I&#8217;m adding missing menu items. Fixing obscure corner cases. Fighting inconsistencies in operating system APIs. Spotting misplaced pixels. Adding missing keyboard shortcuts.</p>
<p><em>Nothing interesting to blog about!</em></p>
<p>But still, methinks the difference between software that is merely &#8220;good&#8221; and software that is &#8220;great&#8221; is in the details. And <em>only</em> in the details.</p>
<p>I&#8217;ll just take care of tons of more details. Maybe it will result in something good.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/M5DmHTBqd1g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/11/22/cool-tech-vs-boring-details/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/11/22/cool-tech-vs-boring-details/</feedburner:origLink></item>
		<item>
		<title>Crunchtime!</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/qLCpnusDX8M/</link>
		<comments>http://aras-p.info/blog/2008/11/10/crunchtime/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 13:09:14 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=239</guid>
		<description><![CDATA[A few weeks ago it was all calm in the source control. Now it&#8217;s crunchtime!

I&#8217;m the master of svn deception. I do tons of useless commits just so that the stats look good. Yeah!
&#8230;ok, back to work.
]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://aras-p.info/blog/2008/10/29/unite-2008/">few weeks ago</a> it was all calm in the source control. Now it&#8217;s crunchtime!</p>
<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/11/crunch.png"><img src="http://aras-p.info/blog/wp-content/uploads/2008/11/crunch.png" alt="" title="Crunchtime!" class="alignnone size-full wp-image-240" /></a></p>
<p>I&#8217;m the master of svn deception. I do tons of useless commits just so that the stats look good. Yeah!</p>
<p>&#8230;ok, back to work.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/qLCpnusDX8M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/11/10/crunchtime/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/11/10/crunchtime/</feedburner:origLink></item>
		<item>
		<title>Windows 7</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/arkXOXPErKk/</link>
		<comments>http://aras-p.info/blog/2008/11/03/windows-7/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:28:03 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=237</guid>
		<description><![CDATA[After a steaming pile of poo that is Windows Vista, looks like Windows 7 will be something that is done right.
Ok, to be fair, Vista has lots of new features and improvements under the hood. Now, I haven&#8217;t used them, but transactional file system, exposed low level APIs to get detailed memory/IO stats, etc. etc. [...]]]></description>
			<content:encoded><![CDATA[<p>After a steaming pile of poo that is Windows Vista, looks like <a href="http://blogs.msdn.com/e7/archive/2008/11/01/back-from-the-pdc-next-up-winhec.aspx">Windows 7</a> will be something that is done right.</p>
<p>Ok, to be fair, Vista has lots of new features and improvements under the hood. Now, I haven&#8217;t used them, but <a href="http://en.wikipedia.org/wiki/Transactional_NTFS">transactional file system</a>, exposed low level APIs to get detailed memory/IO stats, etc. etc. sound like cool &#038; useful stuff. The problem with Vista is that all those core improvements are out-weighted by inconsistent &#038; slow UI and some stupid blunders.</p>
<p>Now, Windows 7 seems to be taking on two things: 1) performance and 2) consistency. Building on all the low level improvements done in Vista, and getting the part that is visible to the user right. Yay if Microsoft can pull this off. We&#8217;ll see.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/arkXOXPErKk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/11/03/windows-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/11/03/windows-7/</feedburner:origLink></item>
		<item>
		<title>The awesome support we do</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/NCerq9IhseE/</link>
		<comments>http://aras-p.info/blog/2008/10/30/the-awesome-support-we-do/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 07:00:47 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=235</guid>
		<description><![CDATA[Yesterday&#8217;s experience catching up with Unity forums, as I remember it:
Take a quick look at zillions of new posts.
Answer about five questions with &#8220;what&#8217;s the value of your camera&#8217;s near plane?&#8221;.
There should be some way to automate all of this. For every 20th question, reply with &#8220;increase your near plane!&#8221;, or something.
]]></description>
			<content:encoded><![CDATA[<p>Yesterday&#8217;s experience catching up with Unity forums, as I remember it:</p>
<p>Take a quick look at zillions of new posts.</p>
<p>Answer about five questions with &#8220;what&#8217;s the value of your camera&#8217;s near plane?&#8221;.</p>
<p>There should be some way to automate all of this. For every 20th question, reply with &#8220;increase your near plane!&#8221;, or something.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/NCerq9IhseE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/10/30/the-awesome-support-we-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/10/30/the-awesome-support-we-do/</feedburner:origLink></item>
		<item>
		<title>Unite 2008</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/ikyrpk2GFFs/</link>
		<comments>http://aras-p.info/blog/2008/10/29/unite-2008/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 20:24:35 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=225</guid>
		<description><![CDATA[Spent last week at our conference, Unite 2008. Lots of people, lots of stuff and goodness, tired as hell, but almost recovered already.
We showed a glimpse of Unity editor for Windows at the keynote, so it is public now &#8211; yes, we are working on Windows toolchain. About the time! This is the major area [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/10/unitea.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2008/10/unitea-150x150.jpg" alt="" title="Unite logo" width="150" height="150" class="alignright size-thumbnail wp-image-226" /></a>Spent last week at our conference, <a href="http://unity3d.com/unite/">Unite 2008</a>. Lots of people, lots of stuff and goodness, tired as hell, but almost recovered already.</p>
<p>We showed a glimpse of Unity editor for Windows at the keynote, so it is public now &#8211; yes, we are working on Windows toolchain. About the time! This is the major area I&#8217;m spending time these days &#8211; Windows, Windows, Windows. Learning WinAPI as I cruise along :) Before Unity 2.1 I spent months fixing tons of small issues, now I&#8217;m spending months doing tons of small Windows related things. Someday I&#8217;ll get back to doing tons of small things on the rendering side.</p>
<p>Here&#8217;s a couple of random photos that I <del datetime="2008-10-29T17:09:08+00:00">stole</del><ins datetime="2008-10-29T17:09:08+00:00">borrowed</ins> from Mantas:</p>
<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/10/unitec.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2008/10/unitec-300x199.jpg" alt="" title="Keynote" width="300" height="199" class="alignnone size-medium wp-image-228" /></a><br />
Keynote in front of a Sentinel from The Matrix.</p>
<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/10/united.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2008/10/united-300x199.jpg" alt="" title="Talking" width="300" height="199" class="alignnone size-medium wp-image-229" /></a><br />
Presenters talking.</p>
<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/10/unitee.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2008/10/unitee-300x199.jpg" alt="" title="Listening" width="300" height="199" class="alignnone size-medium wp-image-230" /></a><br />
People listening!</p>
<p><a href="http://aras-p.info/blog/wp-content/uploads/2008/10/uniteb.jpg"><img src="http://aras-p.info/blog/wp-content/uploads/2008/10/uniteb-300x199.jpg" alt="" title="I don&#039;t know this guy" width="300" height="199" class="alignnone size-medium wp-image-227" /></a><br />
I don&#8217;t know that guy in the center. Probably some stupid outsider. Really!</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/ikyrpk2GFFs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/10/29/unite-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/10/29/unite-2008/</feedburner:origLink></item>
		<item>
		<title>Implicit to-pointer operators must die!</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/4pbLxrtkutk/</link>
		<comments>http://aras-p.info/blog/2008/10/09/implicit-to-pointer-operators-must-die/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 13:15:26 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=223</guid>
		<description><![CDATA[For the sake of the nation,
this operator must die!
Seriously. Suppose there is some class, let&#8217;s say ColorRGBAf. That has four floats inside. Now, someone at some point decided to add this operator to it:
operator float* () { /**/ }
operator const float* () const { /**/ }
Probably because it&#8217;s easier to pass color to OpenGL this [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>For the sake of the nation,<br />
this operator must die!</p></blockquote>
<p>Seriously. Suppose there is some class, let&#8217;s say <code>ColorRGBAf</code>. That has four floats inside. Now, someone at some point decided to add this operator to it:</p>
<blockquote><p>operator float* () { /**/ }<br />
operator const float* () const { /**/ }</p></blockquote>
<p>Probably because it&#8217;s easier to pass color to OpenGL this way, or something like that.</p>
<p>This is evil. Like, really <strong>evil</strong>. Especially if that class did not have comparison operators defined, and some totally unrelated code four years later does:</p>
<blockquote><p>if (color != oldColor) { /* &#8230; */ }</p></blockquote>
<p>Ouch! Sounds like someone will spend four hours debugging something that looks like an event routing issue that <em>only</em> happens on Windows and <em>only</em> with optimizations on <em>(yes, I just did that&#8230;)</em>.</p>
<p>What happens here? The compiler takes pointers to two colors and compares <em>the pointers</em>. If for some reason both colors are temporary objects, then it can even happen that <em>both</em> get folded into the same variable/register/whatnot. The pointers are the same. Ouch!</p>
<p>Implicit &#8220;nice&#8221; operators are just disguised evil. Remove that operator, add something like <code>GetPointer()</code> to class if someone really wants to use that, and better even make the comparison operators private and without implementations. Yes. Much better.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/4pbLxrtkutk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/10/09/implicit-to-pointer-operators-must-die/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/10/09/implicit-to-pointer-operators-must-die/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 4.727 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-10 03:44:19 -->
