<?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, 10 Jun 2009 18:58:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</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><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>
		<item>
		<title>How to announce anything</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/0X31ZTIigTA/</link>
		<comments>http://aras-p.info/blog/2008/09/20/how-to-announce-anything/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 04:39:59 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=221</guid>
		<description><![CDATA[I&#8217;m quoting awesome post by Charles Hinshaw from Unity forums:
I vote that we complain enough that they don&#8217;t share plans until everything is 200% done &#8211; I personally don&#8217;t want to know about a new version of Unity until after I have already shipped at least one game built with that version.
Alternately, UT could issue [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m quoting awesome post by Charles Hinshaw from Unity forums:</p>
<blockquote><p>I vote that we complain enough that they don&#8217;t share plans until everything is 200% done &#8211; I personally don&#8217;t want to know about a new version of Unity until after I have already shipped at least one game built with that version.</p>
<p>Alternately, UT could issue press releases that lack any information that might set expectations and/or require approval from third parties: </p>
<blockquote><p>Unity Technologies ApS, announced today that they may be releasing an update to their popular game development software at an undisclosed future time. </p>
<p>From their offices in Copenhagen, Unity Technologies CEO and co-founder, David Helgason, said &#8220;We&#8217;re pretty excited not to announce anything specific about this potential upcoming release as we think that many of our users may be pleased by the addition of some number of features that may not have been present in previous versions of the software.&#8221; </p>
<p>Tom Higgins, Product Evangelist, added &#8220;The features in this software are making it possible for a number of undisclosed companies to work on various projects that may be released in the future. I think all of our users might be inspired by the things that may currently be under development with this future version of Unity.&#8221;</p></blockquote>
<p><em>edit</em>: Uhm, based on the replies that follow, apparently it wasn&#8217;t obvious that I am not seriously requesting this.</p></blockquote>
<p>Way to go! :)</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/0X31ZTIigTA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/09/20/how-to-announce-anything/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/09/20/how-to-announce-anything/</feedburner:origLink></item>
		<item>
		<title>How watchdog threads should NOT be done…</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/BB82OHbpntA/</link>
		<comments>http://aras-p.info/blog/2008/09/05/how-watchdog-threads-should-not-be-done/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 09:48:22 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=207</guid>
		<description><![CDATA[Here, a thread function that checks whether some tool got stuck:

static void WatchdogFunc()
{
    while( true )
    {
        time_t now = time(NULL);
        Mutex::AutoLock lock(g_WatchdogMutex);
        if( now - g_StartTime > [...]]]></description>
			<content:encoded><![CDATA[<p>Here, a thread function that checks whether some tool got stuck:</p>
<blockquote><p><code>
<pre>static void WatchdogFunc()
{
    while( true )
    {
        time_t now = time(NULL);
        Mutex::AutoLock lock(g_WatchdogMutex);
        if( now - g_StartTime > kWatchdogTimeout )
            ComplainLoudlyAndDoSomething();
        Thread::Sleep( 0.1f );
    }
}</pre>
<p></code></p></blockquote>
<p>Mutex is taken because g_StartTime can be occasionally updated by the same tool. Yes, possibly a mutex is an overkill here, and aligned variable + some memory fences should be enough (or just nothing), but hey, this is some random offline tool code.</p>
<p>What is horribly wrong with it?</p>
<p>Mutex is held locked for the whole duration of Sleep! That is, almost all the time; and other thread(s) barely have a chance to ever update g_StartTime.</p>
<p>And this is the code I&#8217;ve written. Oh stupid me.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/BB82OHbpntA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/09/05/how-watchdog-threads-should-not-be-done/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/09/05/how-watchdog-threads-should-not-be-done/</feedburner:origLink></item>
		<item>
		<title>s/deity/demoscene/g</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/26ZjsV2li5Q/</link>
		<comments>http://aras-p.info/blog/2008/09/05/sdeitydemosceneg/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 06:00:12 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[demos]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=204</guid>
		<description><![CDATA[Awesome sillyness: replace deity with demoscene thread on pouët.net.
I have seen things you people wouldn&#8217;t believe
Cubes on fire on the C sixtyfour
I watched glenzvectors on the bigscreen at TP2
All those moments will be lost on the net&#8230; like tears in the rain.
Time for DirectX
]]></description>
			<content:encoded><![CDATA[<p>Awesome sillyness: <a href="http://pouet.net/topic.php?which=5596&#038;page=1">replace deity with demoscene thread</a> on pouët.net.</p>
<blockquote><p>I have seen things you people wouldn&#8217;t believe<br />
Cubes on fire on the C sixtyfour<br />
I watched glenzvectors on the bigscreen at TP2<br />
All those moments will be lost on the net&#8230; like tears in the rain.<br />
Time for DirectX</p></blockquote>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/26ZjsV2li5Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/09/05/sdeitydemosceneg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/09/05/sdeitydemosceneg/</feedburner:origLink></item>
		<item>
		<title>Hardware of the casual gamer</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/ZPfibH_9ml4/</link>
		<comments>http://aras-p.info/blog/2008/08/28/hardware-of-the-casual-gamer/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 18:32:57 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[games]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=200</guid>
		<description><![CDATA[(if this sounds like a rehash of a blog post on blogs.unity3d.com, well, it is&#8230;)
Everyone knows the Valve&#8217;s hardware survey. But what if your target game players are not the traditional &#8220;big budget AAA game&#8221; type? For example, at the moment most Unity Web Player games are oriented to much more casual market, so hardware [...]]]></description>
			<content:encoded><![CDATA[<p><em>(if this sounds like a rehash of a blog post on <a href="http://blogs.unity3d.com/2008/08/01/hardware-of-the-casual-gamer/">blogs.unity3d.com</a>, well, it is&#8230;)</em></p>
<p>Everyone knows the <a href="http://www.steampowered.com/status/survey.html">Valve&#8217;s hardware survey</a>. But what if your target game players are not the traditional &#8220;big budget AAA game&#8221; type? For example, at the moment most Unity Web Player games are oriented to much more casual market, so hardware there might be <em>very</em> different. And indeed, turns out it is quite different.</p>
<p>Without further ado, here&#8217;s the data we have: <a href="http://unity3d.com/webplayer/hwstats/"><strong>Unity Web Player hardware statistics</strong></a>.</p>
<p>It&#8217;s about two million data points since we started gathering it earlier this year.</p>
<p>Some subjective points of interest (I&#8217;ll be using current data for 2008 Q3 here):</p>
<ul>
<li><a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-os.html">Operating systems</a>: Mac OS X is 2.5%, the rest is Windows. 64 bit Windows haven&#8217;t really picked up yet (0.7%). Windows 2000 is dying fast (0.7%). OS X Leopard already took over OS X Tiger.</li>
<li><a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-cpuvendor.html">CPUs</a>: poor Transmeta :) <a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-cores.html">Dual core</a> CPUs are becoming the norm (46%).</li>
<li><a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-gfxcard.html">Graphics cards</a>: quite sad, in fact&#8230; top 15 cards are slow or <em>horribly slow</em>. Capability wise, they are quite good, with <a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-shader.html">about 70%</a> having shader model 2.0 or higher. Shader model 1.x cards are dead. &#8220;<a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-shadergen.html">Can has DX10</a>&#8221; is 2.7%.</li>
<li>Casual machines don&#8217;t have lots of <a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-ram.html">RAM</a>. Nor lots of <a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-vram.html">VRAM</a>.</li>
<li>Most popular nvidia driver? <a href="http://unity3d.com/webplayer/hwstats/pages/web-2008Q3-gfxdriver.html">56.73</a>. Looks like this is the driver that comes integrated in XP SP2&#8230; Now, who says regular people <em>ever</em> update their drivers? Likewise, vga.dll (i.e. standard VGA) is 1.6% of machines; additional 1.5% don&#8217;t report any driver (not sure how that happens&#8230;).</li>
</ul>
<p>So yeah. Casual machines: capabilities quite okay, performance low, low, low. That&#8217;s life.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/ZPfibH_9ml4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/08/28/hardware-of-the-casual-gamer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/08/28/hardware-of-the-casual-gamer/</feedburner:origLink></item>
		<item>
		<title>OpenGL 3: a big step in no direction at all?</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/QVbOqYrf37I/</link>
		<comments>http://aras-p.info/blog/2008/08/20/opengl-3-a-big-step-in-no-direction-at-all/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 09:28:03 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[opengl]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=195</guid>
		<description><![CDATA[Well, the post title pretty much summarizes my take on it, doesn&#8217;t it? I guess I could just stop typing now&#8230; but I won&#8217;t!
So after some promises, delays and a period of deadly silence, OpenGL 3.0 was released.
Response to it was &#8220;interesting&#8220;, to say at least. Some part of that response is related to seriously [...]]]></description>
			<content:encoded><![CDATA[<p>Well, the post title pretty much summarizes my take on it, doesn&#8217;t it? I guess I could just stop typing now&#8230; but I won&#8217;t!</p>
<p>So after some promises, delays and a period of deadly silence, OpenGL 3.0 was <a href="http://www.khronos.org/news/press/releases/khronos_releases_opengl_30_specifications_to_support_latest_generations_of/">released</a>.</p>
<p>Response to it was &#8220;<a href="http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&#038;Number=243193">interesting</a>&#8220;, to say at least. Some part of that response is related to seriously mishandled communication on Khronos part. Some part is because GL 3.0 is not what it was promised to be. Let&#8217;s just ignore the communication issue, it does not affect OpenGL <em>itself</em> in a direct way (it affects the developer community though).</p>
<p><em>By the way, I borrowed part of the post title from a <a href="http://fireuser.com/blog/opengl_30_a_big_step_in_the_right_direction/">blog post</a> linked from opengl.org. In general, I do not agree with that blog post, but it&#8217;s a valid point of view. Unlike some other <a href="http://zerias.blogspot.com/2008/08/why-fud-against-opengl-30.html">blog posts</a> linked from opengl.org that are just pure garbage&#8230;<br />
</em></p>
<p>I am not sure what are the goals of OpenGL at this point. OpenGL&#8217;s current position, as far as games are concerned, seems to be roughly this:</p>
<blockquote><p>Be the graphics API on various platforms where no alternatives are available.</p></blockquote>
<p>Why? Because Windows has got D3D, which is far more stable, comes with useful tools, more often updated and actually works for variety of users (I&#8217;ll get to this point in a second). Mobile platforms have OpenGL ES, which is decent. All consoles have their own APIs (some of them similar to D3D, <em>none</em> of them similar to GL). So that leaves OpenGL as the choice on OS X, Linux and such. Not because it&#8217;s better. Because it&#8217;s the only choice.</p>
<p><em>&#8220;Oh, but look, <a href="http://www.idsoftware.com/">id</a> uses OpenGL! Two other games use OpenGL as well!&#8221;</em> Well, good for them. But they are in a different league than &#8220;the rest of us&#8221;. For <em>some games</em>, driver writers will do whatever it takes to get those games running correct &#038; fast. Surprise surprise, id games fall into this category. For the rest of us &#8211; no such luxury. Hey, try talking to your friendly IHV, the most likely answer is <em>&#8220;yeah, but are really busy with some high profile games right now, ping us back in two months&#8221;</em>. After two months, repeat.</p>
<p>So the rest comes from somone who is <em>not</em> working on the high-profile games that IHVs specially tune drivers to.</p>
<p>If OpenGL&#8217;s goals are to stay in this current position, then GL 3.0 is okay. It adds some new features, brings some extensions into core, hey, it even says &#8220;it&#8217;s quite likely that maybe perhaps someday some of the old cruft in the API will be removed, if we feel like it&#8221;. No problem with that.</p>
<p>However, OpenGL is advertised as something different, as if it wants to:</p>
<blockquote><p>Be <strong>the</strong> graphics API on <strong>various platforms</strong>.</p></blockquote>
<p>Which is quite different from it&#8217;s current position. I&#8217;m not sure if that&#8217;s the goal of OpenGL. Myself, I don&#8217;t care about the mythical cross-platform API that would <em>actually work</em> on those different platforms. API is a tool to do stuff; if different platforms have different APIs &#8211; no problem with that.</p>
<p>However, if OpenGL <em>wants</em> to achieve this advertised goal, it has to do several things. First and foremost:</p>
<p><strong>Actually work</strong></p>
<p>Stable drivers and runtime. In it&#8217;s current state, GL is too complex to implement good quality drivers/runtime. Complexity can be reduced in several ways:</p>
<ul>
<li>Cleanup the API. This was what GL 3.0 was supposed to be. Actual 3.0 did not do any of that, instead it just postponed the cleanup &#8220;until we feel like it&#8221;.</li>
<li>Share some of the hard work. Why does everyone and their dog have to write GLSL preprocessor, lexer, parser and basic optimizer themselves? Define precompiled shader format, write frontend once, make it open. This would also be actually useful to reduce load times.</li>
</ul>
<p>GL 3.0 could have done both of the above, instead it did none. It could have cleaned up the API, and provide one platform independent GL 1.x/2.x library that calls into actual 3.0 runtime. All the fixed function, immediate mode, display lists, whatever would be in one nice library. Even existing apps could continue to function transparently this way (with the benefit of actually simpler = more stable drivers).</p>
<p><strong>Support platforms/hardware/features user needs</strong></p>
<p>This is of course dependent on the user in question. For someone like <a href="http://unity3d.com/">us</a>, we still have to support 10 year old hardware.</p>
<p>D3D9 does a fine job for that (provided you have drivers installed, and DX9 runtime installed &#8211; which comes included in XP SP2 and upwards). OpenGL 2.1 and earlier would do a fine job for that, provided it would &#8220;actually work&#8221; (see above).</p>
<p>If GL 3.0 would be as was originally promised &#8211; almost new API, shader model 2.0+ hardware, it would be sort of fine. In our case, that would mean writing and supporting two renderers &#8211; &#8220;old GL&#8221; and &#8220;new GL&#8221;, where old one would be used on old hardware or old platforms where &#8220;new GL&#8221; is not available. If the new runtime were much leaner, much more stable and generally nicer, this would not be a big problem.</p>
<p>With actual GL 3.0, in theory one does not have to write two renderers. Minimum hardware level for GL 3.0 is shader model 4+ though. So to support both old hardware/platforms and new hardware/platforms, quite a lot of duplication has to be done. Especially if you intend to go towards proposed &#8220;future GL path&#8221;, i.e. start dropping deprecated functionality from the codebase. At which point you&#8217;ll probably write two separate renderers already. So we&#8217;re back to where original GL 3.0 would have been, just without any extra niceness/stability/leanness right now.</p>
<p>Oh, and look at <a href="http://www.khronos.org/library/detail/2008_siggraph_opengl_bof_slides/">vendor announcements</a> from 2008 OpenGL BOF. NVIDIA: we have almost full drivers now. AMD: we&#8217;re committed to having drivers. Intel: look for GL 3.0 on future platforms. In other words, looks like current Intel&#8217;s cards won&#8217;t ever have GL 3.0 drivers. And in our target market, Intel has the majority of cards.</p>
<p>That sounds very much like &#8220;just ignore whole GL 3.0 thing&#8221; plan to me.</p>
<p><strong>Be nice</strong></p>
<p>This is a point of far lesser importance than &#8220;actually work&#8221; and &#8220;support what is needed&#8221; ones. Having good tools (PIX, &#8230;), documentation, code examples etc. is nice. But not much more; being nicest API in the world does not do much if it does not actually work or does not support what you need. Even in this area, actual GL 3.0 is <em>not</em> nice &#8211; it&#8217;s full of redundancies and crap that goes 15 years back in history.</p>
<p><strong>Summing it up</strong></p>
<p>To me, GL 3.0 looks like a blunder. Instead of fixing the core problems, they just postponed that. Well, <em>Keep up the good work!</em></p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/QVbOqYrf37I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/08/20/opengl-3-a-big-step-in-no-direction-at-all/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/08/20/opengl-3-a-big-step-in-no-direction-at-all/</feedburner:origLink></item>
		<item>
		<title>Uh-oh, this can’t be good</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/f-EuAd1ybtA/</link>
		<comments>http://aras-p.info/blog/2008/08/06/uh-oh-this-cant-be-good/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 09:21:32 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=192</guid>
		<description><![CDATA[Can this lead to anything good when I&#8217;m starting to write lines like this myself?
my $filter = join &#8216; and &#8216;, map { &#8220;agr.$_ = $temp.$_&#8221; } split(/, /, $fields);
I know, it&#8217;s not that scary, and does not involve even a single regexp, but still&#8230;
]]></description>
			<content:encoded><![CDATA[<p>Can this lead to <em>anything</em> good when I&#8217;m starting to write lines like this <em>myself</em>?</p>
<blockquote><p>my $filter = join &#8216; and &#8216;, map { &#8220;agr.$_ = $temp.$_&#8221; } split(/, /, $fields);</p></blockquote>
<p>I know, it&#8217;s not <em>that</em> scary, and does not involve even a single regexp, but still&#8230;</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/f-EuAd1ybtA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/08/06/uh-oh-this-cant-be-good/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/08/06/uh-oh-this-cant-be-good/</feedburner:origLink></item>
		<item>
		<title>It must be a bug in OS/compiler/…</title>
		<link>http://feedproxy.google.com/~r/LostInTheTriangles/~3/-VxkXgdj8JY/</link>
		<comments>http://aras-p.info/blog/2008/07/16/it-must-be-a-bug-in-oscompiler/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 20:02:27 +0000</pubDate>
		<dc:creator>Aras Pranckevičius</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://aras-p.info/blog/?p=187</guid>
		<description><![CDATA[Ever looked at the code which is absolutely correct, yet runs incorrectly? Sometimes it looks like a genuine compiler bug. &#8220;I swear, mister! The compiler corrupts my code!&#8221;
Look again. And again. Eventually you&#8217;ll find where your code is broken.
(Of course, in some cases quite often the compiler is broken&#8230; GLSL, anyone?)
Pimp my code, part 15: [...]]]></description>
			<content:encoded><![CDATA[<p>Ever looked at the code which is <em>absolutely correct</em>, yet runs incorrectly? Sometimes it looks like a genuine compiler bug. <em>&#8220;I swear, mister! The compiler corrupts my code!&#8221;</em></p>
<p>Look again. And again. Eventually you&#8217;ll find where your code is broken.</p>
<p><em>(Of course, in some cases quite often the compiler is broken&#8230; GLSL, anyone?)</em></p>
<p><a href="http://wilshipley.com/blog/2008/07/pimp-my-code-part-15-greatest-bug-of.html">Pimp my code, part 15: The Greatest Bug of All</a> says the above in a much nicer way:</p>
<blockquote><p>Maybe the problem was there was some huge bug in Apple&#8217;s Mach, where if you open too many files in a short period of time, the filesystem tried to, like, cache the results, and the cache blew up, and as a result the filesystem incorrectly just would fail to open any more files, instead of flushing the cache.</p>
<p>&#8230;</p>
<p>I&#8217;ve also been around long enough to <em>know</em> that whenever I know the operating system must be bugged, since <em>my</em> code is correct, I should take a damn close look at my code. The old adage (not mine) is that 99% of the time operating system bugs are actually bugs in your program, and the other 1% of the time they are still bugs in your program, so look harder, dammit.</p></blockquote>
<p>A post well worth reading&#8230; about the process of investigating tricky bugs. And sincere as well. It&#8217;s so good that I&#8217;ll just quote it again:</p>
<blockquote><p>It&#8217;s a bug we should have caught. We should have spent the time to get the images in the 10,000 item file. I messed up.</p>
<p>Software is written by humans. Humans get tired. Humans become discouraged. They aren&#8217;t perfect beings. As developers, we want to pretend this isn&#8217;t so, that our software springs from our head whole and immaculate like the goddess Athena. Customers don&#8217;t want to hear us admit that we fail.</p>
<p>The measure of a man cannot be whether he ever makes mistakes, because he <em>will</em> make mistakes. It&#8217;s what he does in response to his mistakes. The same is true of companies.</p>
<p>We have to apologize, we have to fix the problem, and we have to learn from our mistakes.</p></blockquote>
<p>So very true.</p>
<img src="http://feeds.feedburner.com/~r/LostInTheTriangles/~4/-VxkXgdj8JY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://aras-p.info/blog/2008/07/16/it-must-be-a-bug-in-oscompiler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://aras-p.info/blog/2008/07/16/it-must-be-a-bug-in-oscompiler/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.239 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-07-03 15:51:16 -->
