<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Messy Mind &#187; XNA</title>
	<atom:link href="http://www.messy-mind.net/category/xna/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.messy-mind.net</link>
	<description>Welcome to the tangle in my head.</description>
	<lastBuildDate>Sun, 14 Feb 2010 12:06:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Game Creation Program</title>
		<link>http://www.messy-mind.net/2009/aziel/</link>
		<comments>http://www.messy-mind.net/2009/aziel/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 13:41:18 +0000</pubDate>
		<dc:creator>Bicubic</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[Aziel]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.messy-mind.net/?p=471</guid>
		<description><![CDATA[I think its time to write some sort of introduction to our main project. It&#8217;s a game creation program inspired by Game Maker&#8217;s simple user interface, and aimed to fill in the gap between Game Maker and &#8216;real programming&#8217;. Our aim is to make something almost as simple to use initially as Game Maker, but [...]]]></description>
			<content:encoded><![CDATA[<p>I think its time to write some sort of introduction to our main project. It&#8217;s a game creation program inspired by Game Maker&#8217;s simple user interface, and aimed to fill in the gap between Game Maker and &#8216;real programming&#8217;. Our aim is to make something almost as simple to use initially as Game Maker, but at the same time allow more advanced users the freedom to do what they want. Until we think of an actual name for it, its called Aziel. Here&#8217;s some info about it:<br />
<br/><br />
It&#8217;s based on Microsoft&#8217;s XNA Game Framework and C#. This means that you shouldn&#8217;t expect to be able to use it or anything created with it on linux or mac any time soon.<br />
It is aimed at reasonably new computers. DirectX 9 and a graphics card that supports at least shader model 2 is required.<br />
The above requirements mean that games created with it will have all the graphical eye candy you could imagine; distortion, post processing, color filters, normal mapping, you name it.<br />
It is currently scripted in C# only. Python will be added in the near future as the primary scripting language, and later, perhaps other DLR languages such as ruby, lua, lisp, scheme.. etc.<br />
It will be possible to extend most of its functionality to add features that we haven&#8217;t provided in the core libraries or change some existing behaviour. Extensions will be able to add new types of resources to the resource tree. These may be particle editors/systems, or webcam streams, or objects with special functionality, we&#8217;ll try to give as much freedom as possible to extensions.<br />
It is designed with 2d games in mind, but there is absolutely nothing stopping you from using all the power of XNA and drawing 3d objects if you want.<br />
It is laid out somewhat similar to Game Maker, but with a few key differences. The main one is that it uses XNA to render the game assets and maps in the editor, this means that you&#8217;ll be able to get a preview of how the game will look like without having to launch it.<br />
<br/><br />
If you&#8217;re interested in taking a look at the current early progress and participating in testing or providing ideas and feedback, <a href="http://www.messy-mind.net/forum/index.php?topic=4.msg5">head over to the forum and download it.</a> Understand that the progress is indeed early. Do not report bugs at this time. We know there are plenty of them!<br />
<br/><br />
<a href="http://www.messy-mind.net/uploads/2009/09/screenshot.jpg"  rel="shadowbox"><img src="http://www.messy-mind.net/uploads/2009/09/screenshot-300x203.jpg" alt="aziel editor" title="screenshot" width="300" height="203" class="size-medium wp-image-468" /></a></p>

<div class="ngg-galleryoverview" id="ngg-gallery-2-471">


	<!-- Piclense link -->
	<div class="piclenselink">
		<a class="piclenselink" href="javascript:PicLensLite.start({feedUrl:'http://www.messy-mind.net/wp-content/plugins/nextgen-gallery/xml/media-rss.php?gid=2&amp;mode=gallery'});">
			[View with PicLens]		</a>
	</div>
	
	<!-- Thumbnails -->
		
	<div id="ngg-image-16" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.messy-mind.net/wp-content/gallery/aziel/coll1.jpg" rel="shadowbox[post-471];player=img;" title="Almost pixel-perfect collisions driven by Farseer physics engine"  >
				<img title="Collisions 1" alt="Collisions 1" src="http://www.messy-mind.net/wp-content/gallery/aziel/thumbs/thumbs_coll1.jpg" width="150" height="150" />
			</a>
		</div>
	</div>
	 		
	<div id="ngg-image-17" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.messy-mind.net/wp-content/gallery/aziel/coll2.jpg" rel="shadowbox[post-471];player=img;" title="Optional motion blur on all objects using native drawing."  >
				<img title="Collisions 2" alt="Collisions 2" src="http://www.messy-mind.net/wp-content/gallery/aziel/thumbs/thumbs_coll2.jpg" width="150" height="150" />
			</a>
		</div>
	</div>
	 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


<img src="http://www.messy-mind.net/?ak_action=api_record_view&id=471&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.messy-mind.net/2009/aziel/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>First glance at Kill Catalyst</title>
		<link>http://www.messy-mind.net/2009/first-glance/</link>
		<comments>http://www.messy-mind.net/2009/first-glance/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 17:29:01 +0000</pubDate>
		<dc:creator>Bicubic</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[kill catalyst]]></category>

		<guid isPermaLink="false">http://www.messy-mind.net/?p=425</guid>
		<description><![CDATA[The idea for this game dates back to when I first started messing around with game maker, and I shall be explaining more about it in future posts. In a nutshell, its an overhead &#8216;tactical&#8217; shooter with heavy emphasis on light as a gameplay element. Some enemies will lurk in the dark waiting for you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.messy-mind.net/2009/first-glance/kc2/" rel="attachment wp-att-424"><img src="http://www.messy-mind.net/uploads/2009/06/kc11.png" alt="" title="color-transforms-2" class="alignleft size-thumbnail wp-image-423" /></a></p>
<p>The idea for this game dates back to when I first started messing around with game maker, and I shall be explaining more about it in future posts. In a nutshell, its an overhead &#8216;tactical&#8217; shooter with heavy emphasis on light as a gameplay element. Some enemies will lurk in the dark waiting for you to stray from the illuminated areas, others will set up a perimiter and have <i>you</i> lurking in the dark to get an advantage.</p>
<p>As I wrote earlier, I&#8217;ve chosen to go with a deferred rendering approach to handle the number of lights required for this idea. The above screenshot is the current lighting testbed, and its getting close to what I imagined the game to look like. The challenge is going to be to push as many dynamic shadow casting lights as possible. Given the overhead camera view I&#8217;m sure there are some speed-boosting constraints I can impose on how shadows are done, but I haven&#8217;t thought of anything yet.</p>
<p>PS: WT has put up a page for his ongoing art practice. As I understand it, the idea is to spend 90 minutes a day every day to draw pictures inspired by random ideas. Be sure to check it out, link is at the top.</p>
<p><span id="more-425"></span><br />
<img src="http://www.messy-mind.net/uploads/2009/06/kc3.png" alt="kc3" title="kc3" width="555" height="362" class="alignleft size-full wp-image-456" /></p>
<img src="http://www.messy-mind.net/?ak_action=api_record_view&id=425&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.messy-mind.net/2009/first-glance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fast GPU color transforms with XNA</title>
		<link>http://www.messy-mind.net/2008/fast-gpu-color-transforms/</link>
		<comments>http://www.messy-mind.net/2008/fast-gpu-color-transforms/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 18:11:19 +0000</pubDate>
		<dc:creator>Bicubic</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://www.messy-mind.net/?p=359</guid>
		<description><![CDATA[Some time ago I came across a nice Siggraph paper on Using Lookup Tables to Accelerate Color Transformations and since then have been interested in seeing it at work. 
The basic premise is that a 3d texture is used as a lookup table where the input 3d coords represent the input colour. A nice and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.messy-mind.net/uploads/2008/10/color-transforms-2.jpg" rel="shadowbox[post-359];player=img;"><img src="http://www.messy-mind.net/uploads/2008/10/color-transforms-2-150x56.jpg" alt="" title="color-transforms-2" width="150" height="56" class="alignleft size-thumbnail wp-image-333" /></a>Some time ago I came across a nice Siggraph paper on <a href="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html">Using Lookup Tables to Accelerate Color Transformations</a> and since then have been interested in seeing it at work. </p>
<p>The basic premise is that a 3d texture is used as a lookup table where the input 3d coords represent the input colour. A nice and simple fragment shader is then used to access this lookup texture and return the transformed color. Any number of any complexity operations can be stored in the lookup texture as long as you&#8217;re mapping the single input pixel (that is, no neighbours). Gamma correction, contrast, saturation, colorisation, levels, colour keying etc, are all possible in any combination at a fixed small cost.<br />
<span id="more-359"></span></p>
<h4>The basics</h4>
<p>Here&#8217;s how I generate my lookup 3d texture.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">int</span> size <span style="color: #008000;">=</span> <span style="color: #FF0000;">32</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//size of lookup texture</span>
Color<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> colors <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Color<span style="color: #000000;">&#91;</span>size <span style="color: #008000;">*</span> size <span style="color: #008000;">*</span> size<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
Texture3D tex <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Texture3D<span style="color: #000000;">&#40;</span>Device, size, size, size, <span style="color: #FF0000;">1</span>, TextureUsage.<span style="color: #0000FF;">Linear</span>, SurfaceFormat.<span style="color: #0000FF;">Color</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> r <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> r <span style="color: #008000;">&lt;</span> size<span style="color: #008000;">;</span> r<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> g <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> g <span style="color: #008000;">&lt;</span> size<span style="color: #008000;">;</span> g<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> b <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> b <span style="color: #008000;">&lt;</span> size<span style="color: #008000;">;</span> b<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Vector3 inCol <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Vector3<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>r <span style="color: #008000;">/</span> size, <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>g <span style="color: #008000;">/</span> size, <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">float</span><span style="color: #000000;">&#41;</span>b <span style="color: #008000;">/</span> size<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008080; font-style: italic;">//Manipulate the input color in some way here</span>
            Color col <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Color<span style="color: #000000;">&#40;</span>inCol<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            colors<span style="color: #000000;">&#91;</span>r <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>g <span style="color: #008000;">*</span> size<span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>b <span style="color: #008000;">*</span> size <span style="color: #008000;">*</span> size<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> col<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
tex.<span style="color: #0000FF;">SetData</span><span style="color: #008000;">&lt;</span>Color<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>colors<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Not rocket science, is it? We&#8217;ve just created a lookup table that simply maps output = input. Now, to display it. We have a pretty simple effect to do all out work for us. The only calculations it has to perform are the texel offsets explained in the article I linked. I&#8217;m assuming the reader knows enough about XNA to attach this effect so a SpriteBatch but even if not, you&#8217;ll find that in the sample code.</p>

<div class="wp_syntax"><div class="code"><pre class="glsl" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">half</span> lutSize <span style="color: #000066;">=</span> <span style="color: #0000ff;">32</span><span style="color: #000066;">;</span> <span style="color: #666666; font-style: italic;">//some default lookup table size, to be changed by app</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Sampler for texture currently being drawn</span>
<span style="color: #000066; font-weight: bold;">sampler2D</span> tex1 <span style="color: #000066;">:</span> register<span style="color: #000066;">&#40;</span>s0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//Sampler for lookup table</span>
<span style="color: #993333; font-weight: bold;">texture3D</span> cubeTex<span style="color: #000066;">;</span>
<span style="color: #000066; font-weight: bold;">sampler3D</span> cube <span style="color: #000066;">=</span> sampler_state
<span style="color: #000066;">&#123;</span>
Texture <span style="color: #000066;">=</span> <span style="color: #000066;">&lt;</span>cubeTex<span style="color: #000066;">&gt;;</span> 
<span style="color: #666666; font-style: italic;">//We really want triliniear filtering for this sort of thing</span>
MinFilter <span style="color: #000066;">=</span> linear<span style="color: #000066;">;</span>
MagFilter <span style="color: #000066;">=</span> linear<span style="color: #000066;">;</span>
MipFilter <span style="color: #000066;">=</span> linear<span style="color: #000066;">;</span> 
<span style="color: #000066;">&#125;</span><span style="color: #000066;">;</span>
&nbsp;
float4 Fragment<span style="color: #000066;">&#40;</span>float4 incol <span style="color: #000066;">:</span> COLOR<span style="color: #000066;">,</span> float2 UV <span style="color: #000066;">:</span> TEXCOORD0<span style="color: #000066;">&#41;</span> <span style="color: #000066;">:</span> COLOR0
<span style="color: #000066;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Fetch input color</span>
	float4 inCol <span style="color: #000066;">=</span> tex2D<span style="color: #000066;">&#40;</span>tex1<span style="color: #000066;">,</span> UV<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Edge offset (see http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html)</span>
	half3 scale <span style="color: #000066;">=</span> <span style="color: #000066;">&#40;</span>lutSize <span style="color: #000066;">-</span> <span style="color: #0000ff;">1.0</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">/</span> lutSize<span style="color: #000066;">;</span>
	half3 offset <span style="color: #000066;">=</span> <span style="color: #0000ff;">1.0</span> <span style="color: #000066;">/</span> <span style="color: #000066;">&#40;</span><span style="color: #0000ff;">2.0</span> <span style="color: #000066;">*</span> lutSize<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Transform</span>
	float4 outCol <span style="color: #000066;">=</span> tex3D<span style="color: #000066;">&#40;</span>cube<span style="color: #000066;">,</span> scale <span style="color: #000066;">*</span> inCol <span style="color: #000066;">+</span> offset<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Lerp between input and transformed in RGB space based on input vertex alpha</span>
	<span style="color: #000000; font-weight: bold;">return</span> lerp<span style="color: #000066;">&#40;</span>inCol<span style="color: #000066;">,</span> outCol<span style="color: #000066;">,</span> incol<span style="color: #000066;">.</span><span style="color: #006600;">a</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000066;">&#125;</span>
&nbsp;
technique FastTransform
<span style="color: #000066;">&#123;</span>
    pass Pass1
    <span style="color: #000066;">&#123;</span>
        PixelShader <span style="color: #000066;">=</span> compile ps_2_0 Fragment<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
    <span style="color: #000066;">&#125;</span>
<span style="color: #000066;">&#125;</span></pre></div></div>

<p>That&#8217;s it. After generating a lookup table and setting it on the effect, its ready to go. At the moment you&#8217;d see no difference because the lookup table outputs the input colour but you could try something simple like inCol*=2 to do a multiply2x.<br />
That&#8217;s great, but to actually do something meaningful with this you&#8217;ll probably at least want to be able to convert to HSL and back. I&#8217;ve spent some time to write a rudimentary library for performing colour transforms, you&#8217;ll find it in the sample. Still, to see actual use from this technique you&#8217;ll probably want photoshop grade effects; that&#8217;s what I had in mind when I started this. I scurried about the net looking for various algorithms to perform some of the photoshop tasks, like gamma correction, exposure, levels. I gave up on that notion pretty quickly. Some are fairly complex algorithms that make the lookup table generation slow, and I plain didn&#8217;t want to spend hours reinventing the wheel. There&#8217;s a better way.</p>
<h4>Generating the lookup table with image editing software</h4>
<p>Use photoshop for photoshop grade filters, of course! Its quite simple. To start, we need a 2d representation of the identity lookup table. I whipped up a quick routine to do this and figure out the nicest image sizes for me.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> Texture2D LutToTexture2D<span style="color: #000000;">&#40;</span>GraphicsDevice Device, Texture3D lut<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">//Calculate closest to square proportions for 2d table</span>
            <span style="color: #008080; font-style: italic;">//We assume power-of-two sides, otherwise I don't know</span>
            <span style="color: #FF0000;">int</span> size <span style="color: #008000;">=</span> lut.<span style="color: #0000FF;">Width</span><span style="color: #008000;">;</span>
            <span style="color: #FF0000;">int</span> side1 <span style="color: #008000;">=</span> size <span style="color: #008000;">*</span> size<span style="color: #008000;">;</span>
            <span style="color: #FF0000;">int</span> side2 <span style="color: #008000;">=</span> size<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>side1 <span style="color: #008000;">/</span> <span style="color: #FF0000;">2</span> <span style="color: #008000;">&gt;=</span> side2 <span style="color: #008000;">*</span> <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                side1 <span style="color: #008000;">/=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
                side2 <span style="color: #008000;">*=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">//Dump 3d texture into 2d texture</span>
            Color<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> colors <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Color<span style="color: #000000;">&#91;</span>size <span style="color: #008000;">*</span> size <span style="color: #008000;">*</span> size<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
            Texture2D tex <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Texture2D<span style="color: #000000;">&#40;</span>Device, side1, side2, <span style="color: #FF0000;">1</span>, TextureUsage.<span style="color: #0000FF;">Linear</span>, SurfaceFormat.<span style="color: #0000FF;">Color</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            lut.<span style="color: #0000FF;">GetData</span><span style="color: #008000;">&lt;</span>Color<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>colors<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            tex.<span style="color: #0000FF;">SetData</span><span style="color: #008000;">&lt;</span>Color<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>colors<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">return</span> tex<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>A 64px cube unfolds to a nice 512&#215;512 image like this:<br />
<a href="http://www.messy-mind.net/uploads/2008/10/tex.png" rel="shadowbox[post-359];player=img;"><img src="http://www.messy-mind.net/uploads/2008/10/tex-300x300.png" alt="" title="2d lut" width="300" height="300" class="alignnone size-medium wp-image-325" /></a><br />
<a href="http://www.messy-mind.net/uploads/2008/10/color-transforms-1.jpg" rel="shadowbox[post-359];player=img;"><img src="http://www.messy-mind.net/uploads/2008/10/color-transforms-1-150x105.jpg" alt="" title="color-transforms-1" width="150" height="105" class="alignleft size-thumbnail wp-image-328" /></a> Once you have that, feel free to throw it into your favourite image editor and apply any colour transforms you want to it. For the results to be actually meaningful, I took a screenshot of my game, applied adjustment layers to make it look how I want, and then threw them on the lookup table. You can see my setup in the screenshot here.<br />
Finally we load the modified lookup table back in by reversing the above process (see sample), and voila! Lightning fast photoshop grade filters.</p>
<h4>Limitations</h4>
<p>This cake is obviously not free. The lookup tables take up video memory. For compatibility reasons I use SurfaceFormat.Color to represent them which means that one channel (alpha) is wasted; which doesn&#8217;t help either. A 32px cube is negligible, a 64px cube takes up 1mb, a 128px cube takes up 8mb, and the full 256px deal takes up a whopping 64mb. What size should you be using? That depends on the complexity of the transformations you&#8217;re doing. The higher frequency the changes in your function are, the higher resolution table you&#8217;ll need. I find that 64 is acceptable for most stuff. 128 may be needed sometimes (once so far) to closely match photoshop. I find that 8mb is still acceptable today, just make sure that your effect warrants it.</p>
<p>The other limitation is that the procedure is pretty static. If you wanted to change some settings, you&#8217;d have to rebuild the table. One way around this is to create multiple tables with different settings and interpolate between them, but be careful to make sure that your vram expenditure and shader complexity (with the new interpolation which may not look nice in rgb space) are really worth using this for rather than just writing a shader to do the job traditionally.<br />
Alternatively you could have a two step system where you execute a complex shader on the lookup table and use that to do the rest of the work. This would be nice where settings change every once in a while, and you have existing shader code to do the task.</p>
<p>So is this terribly useful at the end of the day? For the inept like me, yes! I like the idea of going into photoshop and making the look I want a lot more than writing fiddly shader code. Its pretty hard to picture this sort of math without actually seeing it at work.</p>
<p><a href='http://www.messy-mind.net/uploads/2008/10/colortransforms.zip'>Download Sample</a></p>
<img src="http://www.messy-mind.net/?ak_action=api_record_view&id=359&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.messy-mind.net/2008/fast-gpu-color-transforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
