<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-790389648997972680</id><updated>2012-02-16T20:07:47.121-08:00</updated><title type='text'>The Code Deposit</title><subtitle type='html'>Whitepapers for the rest of us</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-7447919460484357215</id><published>2011-12-02T09:22:00.000-08:00</published><updated>2011-12-07T15:39:10.216-08:00</updated><title type='text'>Spherical harmonics self-shadowing</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/-scRIghLBJN4/TtkMif23TKI/AAAAAAAAAEE/EG6jOa4CgD8/s1600/sh-selfshadow.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 112px;" src="http://4.bp.blogspot.com/-scRIghLBJN4/TtkMif23TKI/AAAAAAAAAEE/EG6jOa4CgD8/s200/sh-selfshadow.jpg" alt="" id="BLOGGER_PHOTO_ID_5681586191711292578" border="0" /&gt;&lt;/a&gt;&lt;a href="http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_EfficientSelfShadowedRadiosityNormalMapping.pdf"&gt;Valve's self-shadowing radiosity normal maps&lt;/a&gt; concept can be used with spherical harmonics in approximately the same way: Integrate a sphere based on how much light will affect a sample if incoming from numerous sample direction, accounting for collision with other samples due to elevation.&lt;br /&gt;&lt;br /&gt;You can store this as three DXT1 textures, though you can improve quality by packing channels with similar spatial coherence. Coefficients 0, 2, and 6 in particular tend to pack well, since they're all dominated primarily by directions aimed perpendicular to the texture.&lt;br /&gt;&lt;br /&gt;I use the following packing:&lt;br /&gt;Texture 1: Coefs 0, 2, 6&lt;br /&gt;Texture 2: Coefs 1, 4, 5&lt;br /&gt;Texture 3: Coefs 3, 7, 8&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://codedeposit.blogspot.com/2010/01/spherical-harmonics-spoilers.html"&gt;reference an early post on this blog&lt;/a&gt; for code on how to rotate a SH vector by a matrix, in turn allowing you to get it into texture space.  Once you've done that, simply multiply each SH coefficient from the self-shadowing map by the SH coefficients created from your light source (also covered on the previous post) and add together.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-7447919460484357215?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/7447919460484357215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2011/12/spherical-harmonics-self-shadowing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/7447919460484357215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/7447919460484357215'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2011/12/spherical-harmonics-self-shadowing.html' title='Spherical harmonics self-shadowing'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-scRIghLBJN4/TtkMif23TKI/AAAAAAAAAEE/EG6jOa4CgD8/s72-c/sh-selfshadow.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-8197183077114766290</id><published>2011-10-18T20:55:00.000-07:00</published><updated>2011-10-18T21:37:29.437-07:00</updated><title type='text'>Introducing RDX</title><content type='html'>Has it really been a year since the last update?&lt;br /&gt;&lt;br /&gt;Well, things have been chugging along with less discovery and more actual work.  However, development on TDP is largely on hold due to the likely impending release of the Doom 3 source code, which has numerous architectural improvements like rigid-body physics and much better customization of entity networking.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the meantime, however, a component of TDP has been spun off into its own project: The RDX extension language.  Initially planned as a resource manager, it has evolved into a full-fledged programmability API.  The main goal was to have a runtime with very straightforward integration, to the point that you can easily use it for managing your C++ resources, but also to be much higher performance than dynamically-typed interpreted languages, especially when dealing with complex data types such as float vectors.&lt;br /&gt;&lt;br /&gt;Features are still being implemented, but the compiler seems to be stable and load-time conversion to native x86 code is functional.  Expect a real release in a month or two.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/rdx-extension-language/"&gt;The project now has a home on Google Code&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-8197183077114766290?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/8197183077114766290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2011/10/introducing-rdx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/8197183077114766290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/8197183077114766290'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2011/10/introducing-rdx.html' title='Introducing RDX'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-3266199848558543631</id><published>2010-10-07T17:36:00.001-07:00</published><updated>2010-10-10T23:21:28.508-07:00</updated><title type='text'>YCoCg DXT5 - Stripped down and simplified</title><content type='html'>You'll recall some improvements I proposed to the YCoCg DXT5 algorithm a while back.&lt;br /&gt;&lt;br /&gt;There's another realization of it I made recently: As a YUV-style color space, the Co and Cg channels are constrained to a range that's directly proportional to the Y channel.  The addition of the scalar blue channel was mainly introduced to deal with resolution issues that caused banding artifacts on colored objects changing value, but the entire issue there can be sidestepped by simply using the Y channel as a multiplier for the Co and Cg channels, causing them to only respect tone and saturation while the Y channel becomes fully responsible for intensity.&lt;br /&gt;&lt;br /&gt;This is &lt;span style="font-weight:bold;"&gt;not&lt;/span&gt; a quality improvement, in fact it nearly doubles PSNR in testing.  However, it does result in considerable simplification of the algorithm, both on the encode and decode sides, and the perceptual loss compared to the old algorithm is very minimal.&lt;br /&gt;&lt;br /&gt;This also simplifies the algorithm considerably:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;int iY = px[0] + 2*px[1] + px[2];    // 0..1020&lt;br /&gt;int iCo, iCg;&lt;br /&gt;&lt;br /&gt;if (iY == 0)&lt;br /&gt;{&lt;br /&gt;    iCo = 0;&lt;br /&gt;    iCg = 0;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;    iCo = (px[0] + px[1]) * 255 / iY;&lt;br /&gt;    iCg = (px[1] * 2) * 255 / iY;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;px[0] = (unsigned char)iCo;&lt;br /&gt;px[1] = (unsigned char)iCg;&lt;br /&gt;px[2] = 0;&lt;br /&gt;px[3] = (unsigned char)((iY + 2) / 4);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;... And to decode:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;float3 DecodeYCoCgRel(float4 inColor)&lt;br /&gt;{&lt;br /&gt;    return (float3(4.0, 0.0, -4.0) * inColor.r&lt;br /&gt;        + float3(-2.0, 2.0, -2.0) * inColor.g&lt;br /&gt;        + float3(0.0, 0.0, 4.0)) * inColor.a;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_p7tnlbl0cTs/TK5sFtPUqfI/AAAAAAAAADg/qhnCNDrhESo/s1600/coloration.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 179px;" src="http://3.bp.blogspot.com/_p7tnlbl0cTs/TK5sFtPUqfI/AAAAAAAAADg/qhnCNDrhESo/s320/coloration.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5525472638129187314" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;While this does the job with much less perceptual loss than DXT1, and eliminates banding artifacts almost entirely, it is not quite as precise as the old algorithm, so using that is recommended if you need the quality.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-3266199848558543631?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/3266199848558543631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/10/ycocg-dxt5-stripped-down-and-simplified.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/3266199848558543631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/3266199848558543631'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/10/ycocg-dxt5-stripped-down-and-simplified.html' title='YCoCg DXT5 - Stripped down and simplified'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_p7tnlbl0cTs/TK5sFtPUqfI/AAAAAAAAADg/qhnCNDrhESo/s72-c/coloration.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-3120573218124481768</id><published>2010-06-04T16:23:00.000-07:00</published><updated>2010-06-04T16:32:13.374-07:00</updated><title type='text'>... and they're still compressable</title><content type='html'>As a corollary to the last entry, an orthogonal tangent basis is commonly compressed by storing the normal and one of the texture axis vectors, along with a "handedness" multiplier which is either -1 or 1.  The second texture axis is regenerated by taking the cross product of the normal and the stored axis, and multiplying it by the handedness.&lt;br /&gt;&lt;br /&gt;The method I proposed was faulted for breaking this scheme, but there's no break at all.  Since the two texture axes are on the triangle plane, and the normal is perpendicular, you can use the same compression scheme by simply storing the two texture axis vectors, and regenerating the normal by taking the cross product of them, multiplying it by a handedness multiplier, and normalizing it.&lt;br /&gt;&lt;br /&gt;This does not address mirroring concerns if you use my "snap-to-normal" recommendation, though you could detect those cases in a vertex shader by using special handedness values.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-3120573218124481768?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/3120573218124481768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/06/and-theyre-still-compressable.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/3120573218124481768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/3120573218124481768'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/06/and-theyre-still-compressable.html' title='... and they&apos;re still compressable'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-7750839685106402499</id><published>2010-04-22T16:49:00.000-07:00</published><updated>2012-01-07T21:23:05.193-08:00</updated><title type='text'>Tangent-space basis vectors: Don't assume your texture projection is orthogonal</title><content type='html'>How do you generate the tangent vectors, which represent which way the texture axes on a textured triangle, are facing?&lt;br /&gt;&lt;br /&gt;Hitting up Google tends to produce articles like &lt;a href="http://www.terathon.com/code/tangent.html"&gt;this one&lt;/a&gt;, or maybe even that exact one.  I've seen others linked too, the basic formulae tend to be the same.  Have you looked at what you're pasting into your code though?  Have you noticed that you're using the T coordinates to calculate the S vector, and vice versa?   Well, you can look at the underlying math, and you'll find that it's because that's what happens when you assume the normal, S vector, and T vectors form an orthonormal matrix and attempt to invert it, in a sense you're not really using the S and T vectors but rather vectors perpendicular to them.&lt;br /&gt;&lt;br /&gt;But that's fine, right?  I mean, this is an orthogonal matrix, and they are perpendicular to each other, right?  Well, does your texture project on to the triangle with the texture axes at right angles to each other, like a grid?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_p7tnlbl0cTs/S9Dheqg82bI/AAAAAAAAAB4/R2a1-akHNas/s1600/tgen-coords.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 150px;" src="http://1.bp.blogspot.com/_p7tnlbl0cTs/S9Dheqg82bI/AAAAAAAAAB4/R2a1-akHNas/s200/tgen-coords.png" alt="" id="BLOGGER_PHOTO_ID_5463114264925231538" border="0" /&gt;&lt;/a&gt;... Not always?  Well, you might have a problem then!&lt;br /&gt;&lt;br /&gt;So, what's the real answer?&lt;br /&gt;&lt;br /&gt;Well, what do we know?  First, translating the vertex positions will not affect the axial directions.  Second, scrolling the texture will not affect the axial directions.&lt;br /&gt;&lt;br /&gt;So, for triangle (A,B,C), with coordinates (x,y,z,t), we can create a new triangle (LA,LB,LC) and the directions will be the same:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_p7tnlbl0cTs/S9EBF8Z9rCI/AAAAAAAAACA/zt7MAmJM9Lk/s1600/tgen-formula1.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; cursor: pointer; width: 88px; height: 60px;" src="http://4.bp.blogspot.com/_p7tnlbl0cTs/S9EBF8Z9rCI/AAAAAAAAACA/zt7MAmJM9Lk/s200/tgen-formula1.png" alt="" id="BLOGGER_PHOTO_ID_5463149024603122722" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;We also know that both axis directions are on the same plane as the points, so to resolve that, we can to convert this into a local coordinate system and force one axis to zero.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_p7tnlbl0cTs/TAHaQ8Z3bnI/AAAAAAAAADA/LEntYl_Bk9c/s1600/tgen-formula2.png"&gt;&lt;img style="cursor: pointer; width: 170px; height: 67px;" src="http://2.bp.blogspot.com/_p7tnlbl0cTs/TAHaQ8Z3bnI/AAAAAAAAADA/LEntYl_Bk9c/s400/tgen-formula2.png" alt="" id="BLOGGER_PHOTO_ID_5476898606486613618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now we need triangle (Origin, PLB, PLC) in this local coordinate space.  We know PLB[y] is zero since LB was used as the X axis.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_p7tnlbl0cTs/TAHcPPe_B2I/AAAAAAAAADQ/CQhHj3zQaRI/s1600/tgen-formula3.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; cursor: pointer; width: 294px; height: 115px;" src="http://3.bp.blogspot.com/_p7tnlbl0cTs/TAHcPPe_B2I/AAAAAAAAADQ/CQhHj3zQaRI/s400/tgen-formula3.png" alt="" id="BLOGGER_PHOTO_ID_5476900776271873890" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now we can solve this.  Remember that PLB[y] is zero, so...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_p7tnlbl0cTs/S9EHHOg_G_I/AAAAAAAAACw/TyvxD3sS5j0/s1600/tgen-formula4.png"&gt;&lt;img style="cursor: pointer; width: 400px; height: 335px;" src="http://3.bp.blogspot.com/_p7tnlbl0cTs/S9EHHOg_G_I/AAAAAAAAACw/TyvxD3sS5j0/s400/tgen-formula4.png" alt="" id="BLOGGER_PHOTO_ID_5463155643714051058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Do this for both axes and you have your correct texture axis vectors, regardless of the texture projection.  You can then multiply the results by your tangent-space normalmap, normalize the result, and have a proper world-space surface normal.&lt;br /&gt;&lt;br /&gt;As always, the source code spoilers:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;terVec3 lb = ti-&amp;gt;points[1] - ti-&amp;gt;points[0];&lt;br /&gt;terVec3 lc = ti-&amp;gt;points[2] - ti-&amp;gt;points[0];&lt;br /&gt;terVec2 lbt = ti-&amp;gt;texCoords[1] - ti-&amp;gt;texCoords[0];&lt;br /&gt;terVec2 lct = ti-&amp;gt;texCoords[2] - ti-&amp;gt;texCoords[0];&lt;br /&gt;&lt;br /&gt;// Generate local space for the triangle plane&lt;br /&gt;terVec3 localX = lb.Normalize2();&lt;br /&gt;terVec3 localZ = lb.Cross(lc).Normalize2();&lt;br /&gt;terVec3 localY = localX.Cross(localZ).Normalize2();&lt;br /&gt;&lt;br /&gt;// Determine X/Y vectors in local space&lt;br /&gt;float plbx = lb.DotProduct(localX);&lt;br /&gt;terVec2 plc = terVec2(lc.DotProduct(localX), lc.DotProduct(localY));&lt;br /&gt;&lt;br /&gt;terVec2 tsvS, tsvT;&lt;br /&gt;&lt;br /&gt;tsvS[0] = lbt[0] / plbx;&lt;br /&gt;tsvS[1] = (lct[0] - tsvS[0]*plc[0]) / plc[1];&lt;br /&gt;tsvT[0] = lbt[1] / plbx;&lt;br /&gt;tsvT[1] = (lct[1] - tsvT[0]*plc[0]) / plc[1];&lt;br /&gt;&lt;br /&gt;ti-&amp;gt;svec = (localX*tsvS[0] + localY*tsvS[1]).Normalize2();&lt;br /&gt;ti-&amp;gt;tvec = (localX*tsvT[0] + localY*tsvT[1]).Normalize2();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There's an additional special case to be aware of: Mirroring.&lt;br /&gt;&lt;br /&gt;Mirroring across an edge can cause wild changes in a vector's direction, possibly even degenerating it.   There isn't a clear-cut solution to these, but you can work around the problem by snapping the vector to the normal, effectively cancelling it out on the mirroring edge.&lt;br /&gt;&lt;br /&gt;Personally, I check the angle between the two vectors, and if they're more than 90 degrees apart, I cancel them, otherwise I merge them.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-7750839685106402499?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/7750839685106402499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/04/tangent-space-basis-vectors-youre.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/7750839685106402499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/7750839685106402499'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/04/tangent-space-basis-vectors-youre.html' title='Tangent-space basis vectors: Don&apos;t assume your texture projection is orthogonal'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_p7tnlbl0cTs/S9Dheqg82bI/AAAAAAAAAB4/R2a1-akHNas/s72-c/tgen-coords.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-8120434858229906984</id><published>2010-02-11T08:02:00.000-08:00</published><updated>2010-02-11T17:03:14.764-08:00</updated><title type='text'>Volumetric fog spoilers</title><content type='html'>Okay, so you want to make volumetric fog.  Volumetric fog has descended from its days largely as a gimmick to being situationally useful, and there are still some difficulties: It's really difficult to model changes in the light inside the fog.  There are techniques you can use for volumetric shadows within the fog, like rendering the depths of the front and back sides of non-overlapping volumes into a pair of accumulation textures, and using the difference between the two to determine the amount of distance penetrated.&lt;br /&gt;&lt;br /&gt;Let's focus on a simpler implementation though: Planar, infinite, and with a linear transitional region.  A transitional region is nice because it means the fog appears to gradually taper off instead of being conspicuously contained entirely below a flat plane.&lt;br /&gt;&lt;br /&gt;In practice, there is one primary factor that needs to be determined: The amount of fog penetrated by the line from the viewpoint to the surface.  In determining that, the transitional layer and the surface layer actually need to be calculated separately:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Transition layer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_p7tnlbl0cTs/S3ShYV8eH1I/AAAAAAAAABY/2Vp0JOH1AOg/s1600-h/fog-intermediate.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 161px;" src="http://2.bp.blogspot.com/_p7tnlbl0cTs/S3ShYV8eH1I/AAAAAAAAABY/2Vp0JOH1AOg/s200/fog-intermediate.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5437148089722740562" /&gt;&lt;/a&gt;For the transition layer, what you want to do is multiply the distance traveled through the transition layer by the average density of the fog.  Fortunately, due to some quirks of the math involved, there's a very easy way to get this: The midpoint of the entry and exit points of the transitional region will be located at a point where the fog density is equal to the average density passed through.  The entry and exit points can be done by taking the viewpoint and target distances and clamping them to the entry and exit planes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Full-density layer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_p7tnlbl0cTs/S3Sj7oQeEmI/AAAAAAAAABg/WAMfyBjgv94/s1600-h/fog-exterior.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 129px;" src="http://3.bp.blogspot.com/_p7tnlbl0cTs/S3Sj7oQeEmI/AAAAAAAAABg/WAMfyBjgv94/s200/fog-exterior.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5437150894957138530" /&gt;&lt;/a&gt;&lt;br /&gt;The full-density layer is a bit more complex, since it behaves differently whether the camera is inside or outside of the fog.  For a camera inside the fog, the fogged portion is represented by the distance from the camera to the fog plane.  For a camera outside of the fog, the fogged portion is represented by the distance from the object to the fog plane.  If you want to do it in one pass, both of these modes can be represented by dividing one linearly interpolated value by the linearly interpolated distance of the camera-to-point distance relative to the fog plane.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_p7tnlbl0cTs/S3SkEkY6z9I/AAAAAAAAABo/usNXP0qyczc/s1600-h/fog-interior.png"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 161px;" src="http://3.bp.blogspot.com/_p7tnlbl0cTs/S3SkEkY6z9I/AAAAAAAAABo/usNXP0qyczc/s200/fog-interior.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5437151048537657298" /&gt;&lt;/a&gt;&lt;br /&gt;Since the camera being inside or outside the fog is completely determinable in advance, you can easily make permutations based on it and skip a branch in the shader.  With a deferred renderer, you can use depth information and the fog plane to determine all of the distances.  With a forward renderer, most of the distance factors interpolate linearly, allowing you to do some clamps and divides entirely in the shader.&lt;br /&gt;&lt;br /&gt;Regardless of which you use, once you have the complete distance traveled, the most physically accurate determination of the amount still visible as:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:150%;"&gt;min(1, e&lt;/span&gt;&lt;span style="vertical-align:top;font-size:75%;"&gt;-(length(cameraToVert) * coverage * density)&lt;/span&gt;&lt;span style="font-size:150%;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You don't have to use e as the base though: Using 2 is a bit faster, and you can rescale the density coefficient to achieve any behavior you could have attained with using e.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As usual, the shader code spoilers:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;// EncodeFog : Encodes a 4-component vector containing fraction components used&lt;br /&gt;// to calculate fog factor&lt;br /&gt;float4 VEncodeFog(float3 cameraPos, float3 vertPos, float4 fogPlane, float fogTransitionDepth)&lt;br /&gt;{&lt;br /&gt;    float cameraDist, pointDist;&lt;br /&gt;&lt;br /&gt;    cameraDist = dot(cameraPos, fogPlane.xyz);&lt;br /&gt;    pointDist = dot(vertPos, fogPlane.xyz);&lt;br /&gt;&lt;br /&gt;    return float4(cameraDist, fogPlane.w, fogPlane.w - fogTransitionDepth, pointDist);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// PDecodeFog : Returns the fraction of the original scene to display given&lt;br /&gt;// an encoded fog fraction and the camera-to-vertex vector&lt;br /&gt;// rcpFogTransitionDepth = 1/fogTransitionDepth&lt;br /&gt;float PDecodeFog(float4 fogFactors, float3 cameraToVert, float fogDensityScalar, float rcpFogTransitionDepth)&lt;br /&gt;{&lt;br /&gt;    // x = cameraDist, y = shallowFogPlaneDist, z = deepFogPlaneDist (&lt; shallow), w = pointDist&lt;br /&gt;    float3 diffs = fogFactors.wzz - fogFactors.xxw;&lt;br /&gt;&lt;br /&gt;    float cameraToPointDist = diffs.x;&lt;br /&gt;    float cameraToFogDist = diffs.y;&lt;br /&gt;    float nPointToFogDist = diffs.z;&lt;br /&gt;&lt;br /&gt;    float rAbsCameraToPointDist = 1.0 / abs(cameraToPointDist);&lt;br /&gt;&lt;br /&gt;    // Calculate the average density of the transition zone fog&lt;br /&gt;    // Since density is linear, this will be the same as the density at the midpoint of the ray,&lt;br /&gt;    // clamped to the boundaries of the transition zone&lt;br /&gt;    float clampedCameraTransitionPoint = max(fogFactors.z, min(fogFactors.y, fogFactors.x));&lt;br /&gt;    float clampedPointTransitionPoint = max(fogFactors.z, min(fogFactors.y, fogFactors.w));&lt;br /&gt;    float transitionPointAverage = (clampedPointTransitionPoint + clampedCameraTransitionPoint) * 0.5;&lt;br /&gt;&lt;br /&gt;    float transitionAverageDensity = (fogFactors.y - transitionPointAverage) * rcpFogTransitionDepth;&lt;br /&gt;&lt;br /&gt;    // Determine a coverage factor based on the density and the fraction of the ray that passed through the transition zone&lt;br /&gt;    float transitionCoverage = transitionAverageDensity *&lt;br /&gt;        abs(clampedCameraTransitionPoint - clampedPointTransitionPoint) * rAbsCameraToPointDist;&lt;br /&gt;&lt;br /&gt;    // Calculate coverage for the full-density portion of the volume as the fraction of the ray intersecting&lt;br /&gt;    // the bottom part of the transition zone&lt;br /&gt;#    ifdef CAMERA_IN_FOG&lt;br /&gt;    float fullCoverage = cameraToFogDist * rAbsCameraToPointDist;&lt;br /&gt;    if(nPointToFogDist &gt;= 0.0)&lt;br /&gt;        fullCoverage = 1.0;&lt;br /&gt;#    else&lt;br /&gt;    float fullCoverage = max(0.0, nPointToFogDist * rAbsCameraToPointDist);&lt;br /&gt;#    endif&lt;br /&gt;&lt;br /&gt;    float totalCoverage = fullCoverage + transitionCoverage;&lt;br /&gt;&lt;br /&gt;    // Use inverse exponential scaling with distance&lt;br /&gt;    // fogDensityScalar is pre-negated&lt;br /&gt;    return min(1.0, exp2(length(cameraToVert) * totalCoverage * fogDensityScalar));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-8120434858229906984?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/8120434858229906984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2009/11/volumetric-fog-spoilers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/8120434858229906984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/8120434858229906984'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2009/11/volumetric-fog-spoilers.html' title='Volumetric fog spoilers'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_p7tnlbl0cTs/S3ShYV8eH1I/AAAAAAAAABY/2Vp0JOH1AOg/s72-c/fog-intermediate.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-535320741556622578</id><published>2010-02-10T20:10:00.000-08:00</published><updated>2010-02-11T15:29:26.963-08:00</updated><title type='text'>Self-shadowing textures using radial horizon maps</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_p7tnlbl0cTs/S3OTp7HbqbI/AAAAAAAAABQ/d_NxZCCK8f8/s1600-h/fourier_horizon_mapping.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 134px;" src="http://4.bp.blogspot.com/_p7tnlbl0cTs/S3OTp7HbqbI/AAAAAAAAABQ/d_NxZCCK8f8/s200/fourier_horizon_mapping.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5436851523619105202" /&gt;&lt;/a&gt;&lt;br /&gt;I don't think I need to extoll the virtues of self-shadowing textures, so instead, I'll simply present a method for doing them:&lt;br /&gt;&lt;br /&gt;Any given point on a heightmap can represent all of the shadowing from the surrounding heightmap as a waveform h = f(t), where t is a radial angle across the base plane, and h is the sine of the angle from the base plane to the highest-angled heightmap sample in that direction.  h, in other words, is the horizon level for a light coming from that direction.&lt;br /&gt;&lt;br /&gt;Anyway, the method for precomputing this should be pretty obvious: Fire traces from each sample and finding the shallowest angle that will clear all heightmap samples.  Once you have it, it's simply a matter of encoding it, which can be easily done using Fourier series.  Each Fourier band requires 2 coefficients, except the first which requires one since the sine band is zero.  I use 5 coefficients (stored as an RGBA8 and A8), but 3 works acceptably.  More coefficients requires more storage, but produces sharper shadows.&lt;br /&gt;&lt;br /&gt;Fourier series are really straightforward, but here are the usual Cartesian coordinate spoilers:&lt;br /&gt;&lt;br /&gt;Assuming x = sin(t) and y = cos(t)&lt;br /&gt;&lt;br /&gt;[sin(0)] = 0&lt;br /&gt;[cos(0)] = 1&lt;br /&gt;[sin(n)] = x&lt;br /&gt;[cos(n)] = y&lt;br /&gt;[sin(2n)] = 2*x*y&lt;br /&gt;[cos(2n)] = y*y - x*x&lt;br /&gt;&lt;br /&gt;The constant band squared integrates to 1 over a circle, but all other bands integrate to 0.5.  That means you need to double whatever you get from it to reproduce the original waveform.&lt;br /&gt;&lt;br /&gt;There's one other problem, which is that the horizon will move rapidly at shallow angles, right where precision breaks down.  You need more precision at low values, and my recommended way of doing that is storing the sign-preserving square root of the original value, and multiplying the stored value by the absolute value of itself in the shader.&lt;br /&gt;&lt;br /&gt;For added effect, rather than simply doing a comparison of the light angle to the horizon level, you can take the difference of the two, multiply it by some constant, and saturate.  This will produce a softer shadow edge.&lt;br /&gt;&lt;br /&gt;Shader code to decode this, taking a texture coordinate and a tangent-space lighting direction to the light souce:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;float SelfShadowing(float3 tspaceLightDir, float2 tc)&lt;br /&gt;{&lt;br /&gt;    float3 nLightDir = normalize(tspaceLightDir);&lt;br /&gt;    float4 lqCoefs = tex2D(pHorizonLQMap, tc) * 4.0 - 2.0;   // Premultiply by 2&lt;br /&gt;    float cCoef = tex2D(pHorizonCCUMap, tc).x * 2.0 - 1.0;&lt;br /&gt;&lt;br /&gt;    lqCoefs *= abs(lqCoefs);   // Undo dynamic range compression&lt;br /&gt;    cCoef *= abs(cCoef);&lt;br /&gt;&lt;br /&gt;    float2 tspaceRadial = normalize(float3(tspaceLightDir.xy, 0.0)).xy;&lt;br /&gt;&lt;br /&gt;    float3 qmultipliers = tspaceRadial.xyx * tspaceRadial.yyx * float3(2.0, 1.0, -1.0);&lt;br /&gt;&lt;br /&gt;    float horizonLevel = cCoef + dot(lqCoefs.rg, tspaceRadial)&lt;br /&gt;        + dot(lqCoefs.baa, qmultipliers);&lt;br /&gt;&lt;br /&gt;    return saturate(0.5 + 20.0*(tspaceLightDir.z - horizonLevel));&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;An additional optimization would be to exploit the fact that the range of the coefficients other than the constant band is not -1..1, but rather, -2/pi..2/pi.  Expanding this to -1..1 gives you a good deal of additional precision.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-535320741556622578?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/535320741556622578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/02/self-texturing-shadows-using-radial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/535320741556622578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/535320741556622578'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/02/self-texturing-shadows-using-radial.html' title='Self-shadowing textures using radial horizon maps'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_p7tnlbl0cTs/S3OTp7HbqbI/AAAAAAAAABQ/d_NxZCCK8f8/s72-c/fourier_horizon_mapping.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-4885403825189700778</id><published>2010-01-18T03:06:00.000-08:00</published><updated>2011-12-02T09:22:32.323-08:00</updated><title type='text'>Spherical harmonics spoilers</title><content type='html'>Spherical harmonics seems to have some impenetrable level of difficulty, especially among the indie scene which has little to go off of other than a few presentations and whitepapers, some of which even contain incorrect information (i.e. one of the formulas in the Sony paper on the topic is incorrect), and most of which are still using ZYZ rotations because it's so hard to find how to do a matrix rotation.&lt;br /&gt;&lt;br /&gt;Hao Chen and Xinguo Liu did a presentation at SIGGRAPH '08 and the &lt;a href="http://developer.amd.com/documentation/presentations/legacy/S2008-Chen-Lighting_and_Material_of_Halo3.pdf"&gt;slides from it&lt;/a&gt; contain a good deal of useful stuff, nevermind one of the ONLY easy-to-find rotate-by-matrix functions.  It also treats the Z axis a bit awkwardly, so I patched the rotation code up a bit, and a pre-integrated cosine convolution filter so you can easily get SH coefs for directional light.&lt;br /&gt;&lt;br /&gt;There was also gratuitous use of sqrt(3) multipliers, which can be completely eliminated by simply premultiplying or predividing coef #6 by it, which incidentally causes all of the constants and multipliers to resolve to rational numbers.&lt;br /&gt;&lt;br /&gt;As always, you can include multiple lights by simply adding the SH coefs for them together.  If you want specular, you can approximate a directional light by using the linear component to determine the direction, and constant component to determine the color.  You can do this per-channel, or use the average values to determine the direction and do it once.&lt;br /&gt;&lt;br /&gt;Here are the spoilers:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;#define SH_AMBIENT_FACTOR   (0.25f)&lt;br /&gt;#define SH_LINEAR_FACTOR    (0.5f)&lt;br /&gt;#define SH_QUADRATIC_FACTOR (0.3125f)&lt;br /&gt;&lt;br /&gt;void LambertDiffuseToSHCoefs(const terVec3 &amp;amp;dir, float out[9])&lt;br /&gt;{&lt;br /&gt;  // Constant&lt;br /&gt;  out[0] = 1.0f * SH_AMBIENT_FACTOR;&lt;br /&gt;&lt;br /&gt;  // Linear&lt;br /&gt;  out[1] = dir[1] * SH_LINEAR_FACTOR;&lt;br /&gt;  out[2] = dir[2] * SH_LINEAR_FACTOR;&lt;br /&gt;  out[3] = dir[0] * SH_LINEAR_FACTOR;&lt;br /&gt;&lt;br /&gt;  // Quadratics&lt;br /&gt;  out[4] = ( dir[0]*dir[1] ) * 3.0f*SH_QUADRATIC_FACTOR;&lt;br /&gt;  out[5] = ( dir[1]*dir[2] ) * 3.0f*SH_QUADRATIC_FACTOR;&lt;br /&gt;  out[6] = ( 1.5f*( dir[2]*dir[2] ) - 0.5f ) * SH_QUADRATIC_FACTOR;&lt;br /&gt;  out[7] = ( dir[0]*dir[2] ) * 3.0f*SH_QUADRATIC_FACTOR;&lt;br /&gt;  out[8] = 0.5f*( dir[0]*dir[0] - dir[1]*dir[1] ) * 3.0f*SH_QUADRATIC_FACTOR;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void RotateCoefsByMatrix(float outCoefs[9], const float pIn[9], const terMat3x3 &amp;amp;rMat)&lt;br /&gt;{&lt;br /&gt;  // DC&lt;br /&gt;  outCoefs[0] = pIn[0];&lt;br /&gt;&lt;br /&gt;  // Linear&lt;br /&gt;  outCoefs[1] = rMat[1][0]*pIn[3] + rMat[1][1]*pIn[1] + rMat[1][2]*pIn[2];&lt;br /&gt;  outCoefs[2] = rMat[2][0]*pIn[3] + rMat[2][1]*pIn[1] + rMat[2][2]*pIn[2];&lt;br /&gt;  outCoefs[3] = rMat[0][0]*pIn[3] + rMat[0][1]*pIn[1] + rMat[0][2]*pIn[2];&lt;br /&gt;&lt;br /&gt;  // Quadratics&lt;br /&gt;  outCoefs[4] = (&lt;br /&gt;        ( rMat[0][0]*rMat[1][1] + rMat[0][1]*rMat[1][0] ) * ( pIn[4] )&lt;br /&gt;      + ( rMat[0][1]*rMat[1][2] + rMat[0][2]*rMat[1][1] ) * ( pIn[5] )&lt;br /&gt;      + ( rMat[0][2]*rMat[1][0] + rMat[0][0]*rMat[1][2] ) * ( pIn[7] )&lt;br /&gt;      + ( rMat[0][0]*rMat[1][0] ) * ( pIn[8] )&lt;br /&gt;      + ( rMat[0][1]*rMat[1][1] ) * ( -pIn[8] )&lt;br /&gt;      + ( rMat[0][2]*rMat[1][2] ) * ( 3.0f*pIn[6] )&lt;br /&gt;      );&lt;br /&gt;&lt;br /&gt;  outCoefs[5] =  (&lt;br /&gt;         ( rMat[1][0]*rMat[2][1] + rMat[1][1]*rMat[2][0] ) * ( pIn[4] )&lt;br /&gt;       + ( rMat[1][1]*rMat[2][2] + rMat[1][2]*rMat[2][1] ) * ( pIn[5] )&lt;br /&gt;       + ( rMat[1][2]*rMat[2][0] + rMat[1][0]*rMat[2][2] ) * ( pIn[7] )&lt;br /&gt;       + ( rMat[1][0]*rMat[2][0] ) * ( pIn[8] )&lt;br /&gt;       + ( rMat[1][1]*rMat[2][1] ) * ( -pIn[8] )&lt;br /&gt;       + ( rMat[1][2]*rMat[2][2] ) * ( 3.0f*pIn[6] )&lt;br /&gt;       );&lt;br /&gt;&lt;br /&gt;  outCoefs[6] = (&lt;br /&gt;              ( rMat[2][1]*rMat[2][0] ) * ( pIn[4] )&lt;br /&gt;       +      ( rMat[2][2]*rMat[2][1] ) * ( pIn[5] )&lt;br /&gt;       +      ( rMat[2][0]*rMat[2][2] ) * ( pIn[7] )&lt;br /&gt;       + 0.5f*( rMat[2][0]*rMat[2][0] ) * ( pIn[8])&lt;br /&gt;       + 0.5f*( rMat[2][1]*rMat[2][1] ) * ( -pIn[8])&lt;br /&gt;       + 1.5f*( rMat[2][2]*rMat[2][2] ) * ( pIn[6] )&lt;br /&gt;       - 0.5f * ( pIn[6] )&lt;br /&gt;          );&lt;br /&gt;&lt;br /&gt;  outCoefs[7] =  (&lt;br /&gt;         ( rMat[0][0]*rMat[2][1] + rMat[0][1]*rMat[2][0] ) * ( pIn[4] )&lt;br /&gt;       + ( rMat[0][1]*rMat[2][2] + rMat[0][2]*rMat[2][1] ) * ( pIn[5] )&lt;br /&gt;       + ( rMat[0][2]*rMat[2][0] + rMat[0][0]*rMat[2][2] ) * ( pIn[7] )&lt;br /&gt;       + ( rMat[0][0]*rMat[2][0] ) * ( pIn[8] )&lt;br /&gt;       + ( rMat[0][1]*rMat[2][1] ) * ( -pIn[8] )&lt;br /&gt;       + ( rMat[0][2]*rMat[2][2] ) * ( 3.0f*pIn[6] )&lt;br /&gt;       );&lt;br /&gt;&lt;br /&gt;  outCoefs[8] = (&lt;br /&gt;              ( rMat[0][1]*rMat[0][0] - rMat[1][1]*rMat[1][0] ) * ( pIn[4] )&lt;br /&gt;        +     ( rMat[0][2]*rMat[0][1] - rMat[1][2]*rMat[1][1] ) * ( pIn[5] )&lt;br /&gt;        +     ( rMat[0][0]*rMat[0][2] - rMat[1][0]*rMat[1][2] ) * ( pIn[7] )&lt;br /&gt;        +0.5f*( rMat[0][0]*rMat[0][0] - rMat[1][0]*rMat[1][0] ) * ( pIn[8] )&lt;br /&gt;        +0.5f*( rMat[0][1]*rMat[0][1] - rMat[1][1]*rMat[1][1] ) * ( -pIn[8] )&lt;br /&gt;        +0.5f*( rMat[0][2]*rMat[0][2] - rMat[1][2]*rMat[1][2] ) * ( 3.0f*pIn[6] )&lt;br /&gt;         );&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;... and to sample it in the shader ...&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;float3 SampleSHQuadratic(float3 dir, float3 shVector[9])&lt;br /&gt;{&lt;br /&gt;  float3 ds1 = dir.xyz*dir.xyz;&lt;br /&gt;  float3 ds2 = dir*dir.yzx;    // xy, zy, xz&lt;br /&gt;&lt;br /&gt;  float3 v = shVector[0];&lt;br /&gt;&lt;br /&gt;  v += dir.y * shVector[1];&lt;br /&gt;  v += dir.z * shVector[2];&lt;br /&gt;  v += dir.x * shVector[3];&lt;br /&gt;&lt;br /&gt;  v += ds2.x * shVector[4];&lt;br /&gt;  v += ds2.y * shVector[5];&lt;br /&gt;  v += (ds1.z * 1.5 - 0.5) * shVector[6];&lt;br /&gt;  v += ds2.z * shVector[7];&lt;br /&gt;  v += (ds1.x - ds1.y) * 0.5 * shVector[8];&lt;br /&gt;&lt;br /&gt;  return v;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For Monte Carlo integration, take sampling points, feed direction "dir" to the following function to get multipliers for each coefficient, then multiply by the intensity in that direction.  Divide the total by the number of sampling points:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;void SHForDirection(const terVec3 &amp;amp;dir, float out[9])&lt;br /&gt;{&lt;br /&gt;  // Constant&lt;br /&gt;  out[0] = 1.0f;&lt;br /&gt;&lt;br /&gt;  // Linear&lt;br /&gt;  out[1] = dir[1] * 3.0f;&lt;br /&gt;  out[2] = dir[2] * 3.0f;&lt;br /&gt;  out[3] = dir[0] * 3.0f;&lt;br /&gt;&lt;br /&gt;  // Quadratics&lt;br /&gt;  out[4] = ( dir[0]*dir[1] ) * 15.0f;&lt;br /&gt;  out[5] = ( dir[1]*dir[2] ) * 15.0f;&lt;br /&gt;  out[6] = ( 1.5f*( dir[2]*dir[2] ) - 0.5f ) * 5.0f;&lt;br /&gt;  out[7] = ( dir[0]*dir[2] ) * 15.0f;&lt;br /&gt;  out[8] = 0.5f*( dir[0]*dir[0] - dir[1]*dir[1] ) * 15.0f;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;... and finally, for a uniformly-distributed random point on a sphere ...&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;terVec3 RandomDirection(int (*randomFunc)(), int randMax)&lt;br /&gt;{&lt;br /&gt;   float u = (((float)randomFunc()) / (float)(randMax - 1))*2.0f - 1.0f;&lt;br /&gt;   float n = sqrtf(1.0f - u*u);&lt;br /&gt;&lt;br /&gt;   float theta = 2.0f * M_PI * (((float)randomFunc()) / (float)(randMax));&lt;br /&gt;&lt;br /&gt;   return terVec3(n * cos(theta), n * sin(theta), u);&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-4885403825189700778?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/4885403825189700778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/01/spherical-harmonics-spoilers.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/4885403825189700778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/4885403825189700778'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/01/spherical-harmonics-spoilers.html' title='Spherical harmonics spoilers'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-209023315235906303</id><published>2010-01-18T02:21:00.000-08:00</published><updated>2010-10-10T21:32:07.568-07:00</updated><title type='text'>2.0 gamma textures and full-range scalars in YCoCg DXT5</title><content type='html'>A few years back there was a &lt;a href="http://developer.nvidia.com/object/real-time-ycocg-dxt-compression.html"&gt;publication on real-time YCoCg DXT5 texture compression&lt;/a&gt;.  There are two improvements on the technique I feel I should present:&lt;br /&gt;&lt;br /&gt;There's a pretty clear problem right off the bat: It's not particularly friendly to linear textures.  If you simply attempt to convert sRGB values into linear space and store the result in YCoCg, you will experience severe banding owing largely to the loss of precision at lower values.  Gamma space provides a lot of precision at lower intensity values where the human visual system is more sensitive.&lt;br /&gt;&lt;br /&gt;sRGB texture modes exist as a method to cheaply convert from gamma space to linear, and are pretty fast since GPUs can just use a look-up table to get the linear values, but YCoCg can't be treated as an sRGB texture and doing sRGB decodes in the shader is fairly slow since it involves a divide, power raise, and conditional.&lt;br /&gt;&lt;br /&gt;This can be resolved first by simply converting from a 2.2-ish sRGB gamma ramp to a 2.0 gamma ramp, which preserves most of the original gamut: 255 input values map to 240 output values, low intensity values maintain most of their precision, and they can be linearized by simply squaring the result in the shader.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another concern, which isn't really one if you're aiming for speed and doing things real-time, but is if you're considering using such a technique for offline processing, is the limited scale factor.  DXT5 provides enough resolution for 32 possible scale factor values, so there isn't any reason to limit it to 1, 2, or 4 if you don't have to.  Using the full range gives you more color resolution to work with.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's some sample code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;unsigned char Linearize(unsigned char inByte)&lt;br /&gt;{&lt;br /&gt;    float srgbVal = ((float)inByte) / 255.0f;&lt;br /&gt;    float linearVal;&lt;br /&gt;&lt;br /&gt;    if(srgbVal &lt; 0.04045)&lt;br /&gt;        linearVal = srgbVal / 12.92f;&lt;br /&gt;    else&lt;br /&gt;        linearVal = pow( (srgbVal + 0.055f) / 1.055f, 2.4f);&lt;br /&gt;&lt;br /&gt;    return (unsigned char)(floor(sqrt(linearVal)* 255.0 + 0.5));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void ConvertBlockToYCoCg(const unsigned char inPixels[16*3], unsigned char outPixels[16*4])&lt;br /&gt;{&lt;br /&gt;    unsigned char linearizedPixels[16*3]; // Convert to linear values&lt;br /&gt;&lt;br /&gt;    for(int i=0;i&lt;16*3;i++)&lt;br /&gt;        linearizedPixels[i] = Linearize(inPixels[i]);&lt;br /&gt;&lt;br /&gt;    // Calculate Co and Cg extents&lt;br /&gt;    int extents = 0;&lt;br /&gt;    int n = 0;&lt;br /&gt;    int iY, iCo, iCg;&lt;br /&gt;    int blockCo[16];&lt;br /&gt;    int blockCg[16];&lt;br /&gt;    const unsigned char *px = linearizedPixels;&lt;br /&gt;    for(int i=0;i&lt;16;i++)&lt;br /&gt;    {&lt;br /&gt;        iCo = (px[0]&lt;&lt;1) - (px[2]&lt;&lt;1);&lt;br /&gt;        iCg = (px[1]&lt;&lt;1) - px[0] - px[2];&lt;br /&gt;        if(-iCo &gt; extents) extents = -iCo;&lt;br /&gt;        if( iCo &gt; extents) extents = iCo;&lt;br /&gt;        if(-iCg &gt; extents) extents = -iCg;&lt;br /&gt;        if( iCg &gt; extents) extents = iCg;&lt;br /&gt;&lt;br /&gt;        blockCo[n] = iCo;&lt;br /&gt;        blockCg[n++] = iCg;&lt;br /&gt;&lt;br /&gt;        px += 3;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Co = -510..510&lt;br /&gt;    // Cg = -510..510&lt;br /&gt;    float scaleFactor = 1.0f;&lt;br /&gt;    if(extents &gt; 127)&lt;br /&gt;        scaleFactor = (float)extents * 4.0f / 510.0f;&lt;br /&gt;&lt;br /&gt;    // Convert to quantized scalefactor&lt;br /&gt;    unsigned char scaleFactorQuantized = (unsigned char)(ceil((scaleFactor - 1.0f) * 31.0f / 3.0f));&lt;br /&gt;&lt;br /&gt;    // Unquantize&lt;br /&gt;    scaleFactor = 1.0f + (float)(scaleFactorQuantized / 31.0f) * 3.0f;&lt;br /&gt;&lt;br /&gt;    unsigned char bVal = (unsigned char)((scaleFactorQuantized &lt;&lt; 3) | (scaleFactorQuantized &gt;&gt; 2));&lt;br /&gt;&lt;br /&gt;    unsigned char *outPx = outPixels;&lt;br /&gt;&lt;br /&gt;    n = 0;&lt;br /&gt;    px = linearizedPixels;&lt;br /&gt;    for(i=0;i&lt;16;i++)&lt;br /&gt;    {&lt;br /&gt;        // Calculate components&lt;br /&gt;        iY = ( px[0] + (px[1]&lt;&lt;1) + px[2] + 2 ) / 4;&lt;br /&gt;        iCo = ((blockCo[n] / scaleFactor) + 128);&lt;br /&gt;        iCg = ((blockCg[n] / scaleFactor) + 128);&lt;br /&gt;&lt;br /&gt;        if(iCo &lt; 0) iCo = 0; else if(iCo &gt; 255) iCo = 255;&lt;br /&gt;        if(iCg &lt; 0) iCg = 0; else if(iCg &gt; 255) iCg = 255;&lt;br /&gt;        if(iY &lt; 0) iY = 0; else if(iY &gt; 255) iY = 255;&lt;br /&gt;&lt;br /&gt;        px += 3;&lt;br /&gt;&lt;br /&gt;        outPx[0] = (unsigned char)iCo;&lt;br /&gt;        outPx[1] = (unsigned char)iCg;&lt;br /&gt;        outPx[2] = bVal;&lt;br /&gt;        outPx[3] = (unsigned char)iY;&lt;br /&gt;&lt;br /&gt;        outPx += 4;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;.... And to decode it in the shader ...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;float3 DecodeYCoCg(float4 inColor)&lt;br /&gt;{&lt;br /&gt;    float3 base = inColor.arg + float3(0, -0.5, -0.5);&lt;br /&gt;    float scale = (inColor.b*0.75 + 0.25);&lt;br /&gt;    float4 multipliers = float4(1.0, 0.0, scale, -scale);&lt;br /&gt;    float3 result;&lt;br /&gt;&lt;br /&gt;    result.r = dot(base, multipliers.xzw);&lt;br /&gt;    result.g = dot(base, multipliers.xyz);&lt;br /&gt;    result.b = dot(base, multipliers.xww);&lt;br /&gt;&lt;br /&gt;    // Convert from 2.0 gamma to linear&lt;br /&gt;    return result*result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-209023315235906303?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/209023315235906303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2010/01/pre-linearized-wide-gamut-dxt5-ycocg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/209023315235906303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/209023315235906303'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2010/01/pre-linearized-wide-gamut-dxt5-ycocg.html' title='2.0 gamma textures and full-range scalars in YCoCg DXT5'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-790389648997972680.post-6580787505108646231</id><published>2009-06-07T18:46:00.000-07:00</published><updated>2009-06-17T21:06:13.866-07:00</updated><title type='text'>Designing TDP's material system</title><content type='html'>TDP is very much a work in progress, but several months were spent on the new renderer before it was even capable of displaying anything.  TDP's asset manager was a large part of this, but a larger part was the material system.  A lot of work went into it to create a powerful material system that would minimize work in the future by making material definitions "smarter."  It would also create a highly scalable and easy-to-refactor system capable of hitting on all cylinders.&lt;br /&gt;&lt;br /&gt;A "hard" material system, which is what I was trying to avoid, works something like this: A material is either left to defaults, in which case the engine uses a hard-coded mechanism to determine the best way to render it, or it's defined as a "custom" material.   Custom materials generally need to be described for every non-default material.   These used to require things very close to the metal, now they're often just done by declaring values to throw at hardware shaders, which is a bit higher-level but still pretty close to the metal.&lt;br /&gt;&lt;br /&gt;There are some flaws with this: It forces artists to deal with rendering concepts that are normally programmer territory, and the only way to deal with some shader customization or other being used repeatedly is either hard-code a new "default" into the engine, or copy/paste a lot of material specifications.&lt;br /&gt;&lt;br /&gt;TDP's material system was designed with a few design goals, largely to address these issues:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Artists should only have to describe the type of surface (or layer) and the assets needed for it, not how to render it.&lt;/li&gt;&lt;li&gt;Material customizations should be reusable.&lt;/li&gt;&lt;li&gt;Rendering paths should be data-driven, not hard-coded.&lt;/li&gt;&lt;li&gt;Asset importation should be automatic, not require an extra step.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The third point was the most difficult one, but all contributed to the creation of a script-based "mediator" which I called "profiles."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Using profiles to describe rendering paths&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Radically-different rendering paths became less of an issue as programmable shaders became standard fare, but it's still necessary: Some features (i.e. texture access in vertex shaders) have major performance differences between hardware, some are not available at all, some (i.e. blends into sRGB framebuffers) behave differently, etc.&lt;br /&gt;&lt;br /&gt;Profiles needed to be "smart" and consistently formulate the best solution.  At the same time, script VMs tend to be slow and executing them every frame is a great way to kill performance.  My solution was to use Lua scripts to create rendering definitions, but also to use a caching scheme to avoid needing to re-execute them unless the rendering environment had changed.&lt;br /&gt;&lt;br /&gt;Profiles are consequently aware of two types of parameters: Static and dynamic.  Static parameters include things that will never change over a material's lifetime: What textures it refers to, graphics settings, etc.  Dynamic parameters include things that might change over its lifetime: How many lights are affecting it, whether it's being viewed from inside a fog volume, etc.&lt;br /&gt;&lt;br /&gt;I call each rendering path generated by an execution of the profile script a "run."  Caching runs was a design challenge of its own.  They needed to be cacheable using only relevant information, but they also needed to be deterministic:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If the static parameters are the same for two materials, they should be able to use the same runs.&lt;/li&gt;&lt;li&gt;Runs should be grouped by their static parameters, but only relevant ones.  This means the same set of static parameters should always be relevant for every run on a material.&lt;/li&gt;&lt;/ul&gt;These created a simple limitation to make sure the static parameter reference list was always deterministic: A static parameter could never be checked by a profile script after a dynamic one.  Of course, static parameters could depend on each other, doing so would drive the permutation count down while still keeping them the same across all runs.&lt;br /&gt;&lt;br /&gt;The dynamic parameter checks were then used as a lookup tree: Each combination of static parameters had one run tree associated with it.  Rendering attempts on a material would traverse the tree, and if they hit an empty node, the profile script would be executed to create a new run.  During that execution, every DynamicParameter function call would attempt to descend the tree, creating a new node if the result hadn't been seen yet, or going down an existing one if it did.  The nodes contained what parameter was checked, and branched based on the results.&lt;br /&gt;&lt;br /&gt;The product of a run, to the engine, was a set of techniques containing several draw layers for a surface for the various reasons that surface could be drawn, as well as the capabilities and limitations of it.  For example, lightmapped surfaces in TDP have a "lightmapBase" technique which is drawn once for every lightmapped surface.  Runs can specify a "maxLights" value which determines how many lights can be merged into that first pass, and if there are too many, they can be rendered using the "pointLight" technique instead and blended over it.&lt;br /&gt;&lt;br /&gt;The techniques contain several layers, each layer corresponding to one pass, and each pass containing a reference to a shader, as well as declarations (which are determined out by the run) to decide which permutation of that shader to use.  Of course, permutations can vary by asset availability, which means profiles will choose shader permutations that assign appropriate default values and avoid unnecessary computation if some component (i.e. a glow overlay) isn't available.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Using templates to describe multiple materials&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The highest-level material definitions in TDP are templates.  Instead of materials needing to be explicitly defined each time, TDP looks for a material definition for a material name, and if that fails, it looks for a "default.mpt" file in every directory in the tree, up to the root directory.  Templates are also Lua scripts, and they're aware of the material name.  This lets them do all kinds of things with it: They can attempt to derive information from the material name itself, and they can form a list of other assets to try loading, like a normal map.&lt;br /&gt;&lt;br /&gt;This makes things pretty easy for material creation: You don't need to create a material, import a normal map, and assign that normalmap to the material inside an asset browser.  Just drop an image with the material name and "_nm" attached to it in the same directory, and it will be automatically detected, imported, and associated with the material.  TDP's terrain uses this quite liberally: To the renderer, terrain is nothing more than a vertex-lit model, but the material system associates numerous other assets with everything in the "terrain" directory like the detailmaps and lightmaps and renders it like actual terrain.&lt;br /&gt;&lt;br /&gt;Importation and processing jobs are another thing recycled heavily using templates.  Most textures are converted to YCoCg DXT5 textures and color-corrected into linear space, which is simply specified as a processing job in one template and then repeated for every material that template applies to.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/790389648997972680-6580787505108646231?l=codedeposit.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codedeposit.blogspot.com/feeds/6580787505108646231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codedeposit.blogspot.com/2009/06/designing-tdps-material-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/6580787505108646231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/790389648997972680/posts/default/6580787505108646231'/><link rel='alternate' type='text/html' href='http://codedeposit.blogspot.com/2009/06/designing-tdps-material-system.html' title='Designing TDP&apos;s material system'/><author><name>OneEightHundred</name><uri>http://www.blogger.com/profile/15917532861521845279</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
