<?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>Sgt. Conker &#187; Charles Humphrey</title>
	<atom:link href="http://www.sgtconker.com/tag/charles-humphrey/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sgtconker.com</link>
	<description>We are &#34;absolutely fine&#34;</description>
	<lastBuildDate>Wed, 06 Jul 2011 13:29:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XNA-UK User Group Prize Giveway!</title>
		<link>http://www.sgtconker.com/2010/08/xna-uk-user-group-prize-giveway/</link>
		<comments>http://www.sgtconker.com/2010/08/xna-uk-user-group-prize-giveway/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:14:16 +0000</pubDate>
		<dc:creator>Captain ZSquare</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[duper]]></category>
		<category><![CDATA[super]]></category>
		<category><![CDATA[user group]]></category>
		<category><![CDATA[XNA-UK]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1613</guid>
		<description><![CDATA[Actually, it's about a Super Duper Prize Giveway at the September 1st meeting of the user group. Also accompanied by presentations about XNA, WP7, shaders and a Xap-a-thon. If you're interested and want more details, jump on their site and read all the details.
]]></description>
			<content:encoded><![CDATA[<p>Actually, it's about a Super Duper Prize Giveway at the September 1st meeting of the user group. Also accompanied by presentations about XNA, WP7, shaders and a Xap-a-thon. If you're interested and want more details, <a href="http://xna-uk.net/blogs/randomchaos/archive/2010/08/17/xblig-uk-xna-uk-ug-super-duper-prize-give-away.aspx">jump on their site and read all the details</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/08/xna-uk-user-group-prize-giveway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links, links, links!</title>
		<link>http://www.sgtconker.com/2010/08/links-links-links/</link>
		<comments>http://www.sgtconker.com/2010/08/links-links-links/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 21:28:22 +0000</pubDate>
		<dc:creator>Captain ZSquare</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Bob Taco Ind]]></category>
		<category><![CDATA[Bounding Boxes]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Content Pipeline]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Shawn Hargreaves]]></category>
		<category><![CDATA[Stephen Styrchak]]></category>
		<category><![CDATA[XNA CCO]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1548</guid>
		<description><![CDATA[We'll start with NemoKrad's BoundingBoxes in XNA 4.0
Next, Stephen Styrchak talks about Debugging the XNA Content Pipeline with C# Express Edition and a bug-fix for Debugging Xbox 360 Content
Bob Taco Industries has two blog posts, one about Turning a Solution into a Template for XNA 4.0 and one about Sizing Apps and Games Properly Using [...]]]></description>
			<content:encoded><![CDATA[<p>We'll start with <a href="http://xna-uk.net/blogs/randomchaos/archive/2010/08/09/boundingbox-s-in-xna-4-0.aspx">NemoKrad's BoundingBoxes in XNA 4.0</a></p>
<p>Next, Stephen Styrchak talks about <a href="http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!502.entry?wa=wsignin1.0&amp;sa=677434802">Debugging the XNA Content Pipeline with C# Express Edition</a> and a <a href="http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!504.entry?wa=wsignin1.0&amp;sa=144184124">bug-fix for Debugging Xbox 360 Content</a></p>
<p>Bob Taco Industries has two blog posts, one about <a href="http://geekswithblogs.net/mikebmcl/archive/2010/08/05/tutorial-turning-a-solution-into-a-template-for-xna-4.0.aspx">Turning a Solution into a Template for XNA 4.0</a> and one about<a href="http://geekswithblogs.net/mikebmcl/archive/2010/08/06/size-apps-and-games-properly-using-the-wp7-emulator.aspx"> Sizing Apps and Games Properly Using the WP7 Emulator</a></p>
<p>Xna Creator's Club Online released some <a href="http://creators.xna.com/en-us/news/educationresources_Aug4">new samples for Windows Phone and XNA Game Studio 4.0</a></p>
<p>And Shawn explains the new <a href="http://blogs.msdn.com/b/shawnhar/archive/2010/08/04/dualtextureeffect.aspx">Dual Texture Effect</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/08/links-links-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brute Force 2D Shadows</title>
		<link>http://www.sgtconker.com/2010/07/brute-force-2d-shadows/</link>
		<comments>http://www.sgtconker.com/2010/07/brute-force-2d-shadows/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 14:25:58 +0000</pubDate>
		<dc:creator>Captain ZSquare</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[2D Shadows]]></category>
		<category><![CDATA[Charles Humphrey]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1514</guid>
		<description><![CDATA[Because he is a much less busy man (it would seem), Charles Humprey made his own implementation for shader-based dynamic 2D shadows and posted it for everyone to see. You can read about it here.
]]></description>
			<content:encoded><![CDATA[<p>Because he is a much less busy man (it would seem), Charles Humprey made his own implementation for shader-based dynamic 2D shadows and posted it for everyone to see. You can read about it <a href="http://xna-uk.net/blogs/randomchaos/archive/2010/06/25/brute-force-2d-shadows-well-sort-of.aspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/07/brute-force-2d-shadows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silent And Quiet</title>
		<link>http://www.sgtconker.com/2010/05/silent-and-quiet/</link>
		<comments>http://www.sgtconker.com/2010/05/silent-and-quiet/#comments</comments>
		<pubDate>Thu, 13 May 2010 17:50:47 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Andy Dunn]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Chris G. Williams]]></category>
		<category><![CDATA[George W. Clingerman]]></category>
		<category><![CDATA[Vincente Cartas]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/05/silent-and-quiet/</guid>
		<description><![CDATA[It’s been some time since the last MVP Watch and it doesn’t seem that much has been missed…
Anyway, George W. “Bugbear” Clingerman feels unhated and so did Vincente “Bête Noire” Cartas, Chris G. “Daggers Drawn” Williams started something, Andy “Jealous as a Barbary Pigeon” Dunn likes to do the opposite, Charles “Demoniacal” Humphrey ain’t impressed, [...]]]></description>
			<content:encoded><![CDATA[<p>It’s been some time since the last MVP Watch and it doesn’t seem that much has been missed…</p>
<p>Anyway, <a href="http://www.xnadevelopment.com/">George W. “Bugbear” Clingerman</a> <a title="Express your hate of this poor chap now!" href="http://twitter.com/clingermangw/status/13729089245">feels unhated</a> and <a title="We hate him. Do you?" href="http://twitter.com/VicenteCartas/status/13729500268">so did</a> <a href="http://kartones.net/blogs/jadengine">Vincente “Bête Noire” Cartas</a>, <a href="http://www.blogusmaximus.net/">Chris G. “Daggers Drawn” Williams</a> <a title="This actually makes it hard to hate this lad but we always prefer the hard job!" href="http://twitter.com/chrisgwilliams/status/13739997883">started something</a>, <a href="http://thezbuffer.com/">Andy “Jealous as a Barbary Pigeon” Dunn</a> <a title="And we hate this laddie for doing so!" href="http://twitter.com/The_Zman/status/13457334932">likes to do the opposite</a>, <a href="http://xna-uk.net/blogs/randomchaos">Charles “Demoniacal” Humphrey</a> <a title="We hate him." href="http://twitter.com/NemoKrad/status/13812012063">ain’t impressed</a>, <a href="http://machaira.spaces.live.com/">Jim “Philophilosophos” Perry</a>&#160;<a title="We cannot help but love this dude." href="http://twitter.com/MachXGames/status/13723767918">reviews movies</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/05/silent-and-quiet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Words And Easy</title>
		<link>http://www.sgtconker.com/2010/04/words-and-easy/</link>
		<comments>http://www.sgtconker.com/2010/04/words-and-easy/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 06:00:50 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Catalin Zima]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[George W. Clingerman]]></category>
		<category><![CDATA[Glenn Wilson]]></category>
		<category><![CDATA[Richard Thomson]]></category>
		<category><![CDATA[Vincente Cartas]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/04/words-and-easy/</guid>
		<description><![CDATA[Richard “Craigellachie” Thomson writes code. Vincente “Tomintoul” Cartas will talk about XNA. Charles “Dufftown” Humphrey writes about code (supposedly Catalin “Linkwood” Zima was in charge to read what was written about code…) and is a lobster.
George W. “Knockando” Clingerman shares links, has a heart of gold and is in good company.
Glenn “Miltonduff” Wilson returns to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://legalizeadulthood.wordpress.com/">Richard “Craigellachie” Thomson</a> <a title="A MVP writing code? No way!!1" href="http://twitter.com/legalizeadulthd/status/12311942117">writes code</a>. <a href="http://kartones.net/blogs/jadengine/">Vincente “Tomintoul” Cartas</a> <a title="There we have it again: MVP is all about being vocal :)" href="http://twitter.com/VicenteCartas/status/12337185278">will talk about XNA</a>. <a href="http://xna-uk.net/blogs/randomchaos">Charles “Dufftown” Humphrey</a> <a title="MVPs do what MVPs do." href="http://www.sgtconker.com/?p=1407">writes about code</a> (supposedly <a href="http://www.catalinzima.com/">Catalin “Linkwood” Zima</a> <a title="…but at the time of this writing the article was still unpublished." href="http://twitter.com/CatalinZima/status/12234234625">was in charge to read what was written about code…</a>) and <a title="Like any other Englishman" href="http://twitter.com/NemoKrad/status/12364194407">is a lobster</a>.</p>
<p><a href="http://www.xnadevelopment.com/">George W. “Knockando” Clingerman</a> <a title="Yes, he can read!" href="http://twitter.com/clingermangw/status/12324658758">shares links</a>, <a title="Sorry, gals, he’s already married." href="http://twitter.com/clingermangw/status/12372887265">has a heart of gold</a> and <a title="He’s the next CliffyB, not that Silva dude!!1" href="http://oxmonline.com/article/features/mag/oxm-vs-xna?page=0%2C1">is in good company</a>.</p>
<p><a href="http://www.virtualrealm.com.au/">Glenn “Miltonduff” Wilson</a> <a title="Welcome back!" href="http://twitter.com/Mykre/status/12374309087">returns to XNA</a> while <a href="http://thezbuffer.com/">Andy “Inchgower” Dunn</a> <a title="Crazy Englishman." href="http://www.indiegameguy.com/blogs/zman/archive/2010/04/23/recovery.aspx">keeps on</a> <a title="Yeah, where? WHERE?!" href="http://www.last.fm/music/Lenny+Kravitz/_/Where+Are+We+Runnin'%3F">runnin’</a>.</p>
<p><em>Ed. <a title="I need to rethink my career…" href="http://www.last.fm/music/Megadeth/Killing+Is+My+Business...And+Business+Is+Good!/Killing+Is+My+Business...and+Business+Is+Good!">Stalking is my business and business is bad</a>. <a title="Cow Zen: rumination is meditation!" href="http://images.google.de/images?q=&quot;the+cow+abides&quot;&amp;hl=en">Moo</a>?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/04/words-and-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Article : Sun- and Lens Flare as a Post Process</title>
		<link>http://www.sgtconker.com/2010/04/article-sun-and-lens-flare-as-a-post-process/</link>
		<comments>http://www.sgtconker.com/2010/04/article-sun-and-lens-flare-as-a-post-process/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 12:12:01 +0000</pubDate>
		<dc:creator>NemoKrad</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Post Processing]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Blacksun]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Lens flare]]></category>
		<category><![CDATA[Post Process]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1407</guid>
		<description><![CDATA[by ]]></description>
			<content:encoded><![CDATA[<h4 style="text-align: center;">by <a href="<a href="http://xna-uk.net/blogs/randomchaos/">Charles Humphrey</a></h4>
<p><img class="alignright" src="http://sgtconker.com/wp-content/uploads/2010/04/sunpostprocess.png" alt="" width="264" height="206" /></p>
<p>Now this sample has come from my current XNA toy which is the Blacksun engine I am currently writing in XNA 3.1. It uses deferred lighting, instancing and a post processing framework that I found on a great site <a href="http://graphicsrunner.blogspot.com/2008/06/post-process-framework-sample.html">here</a>, all I had to do was make it engine ready.</p>
<p>If you want to have a look at the effect in the engine you can see it <a href="http://www.youtube.com/watch?v=DrhF2Bp-95I">here</a>.</p>
<p>This sample is just one of the elements from the post processing framework in the engine, there are none of the other goodies in this sample, just the Sun post process. This sample has also been created using the XNA 4.0 CTP, so I only had one render target to work with at the time. This means that you can't see the sun being culled behind objects in the scene as I can't create a depth map as well as the rendered scene, to be honest, I still don't have that bit of the shader 100% anyway <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><span id="more-1407"></span></p>
<p>So, what do you get in this sample, well, the sun shader and the lens flare effect all in one post process and done in XNA 4.0. It's a pretty simple effect really, taking the suns position in the world, then just finding its screen coordinates on the render target and render the sun flare texture, then render the texture again over a set of offset texture coordinates to give the lens flare effect.</p>
<p>Lets take a look at the code...</p>
<p><strong>Sun.fx</strong></p>
<p>We have a few variables we can pass to the shader to control this effect, the names I hope are quite self explanatory, well most of them</p>
<pre class="brush: csharp; title: ;">
float3 cameraPosition;

float SunSize = 1500;

float Density = 3;
float Exposure = -.1;
float Weight = .25;
float Weight2 = .125;
float Decay = .5;

float3 lightPosition;

float lightIntensity = 10.0f;
float3 Color = float3(1,1,1);

texture flare;
sampler Flare = sampler_state
{
    Texture = (flare);
    AddressU = CLAMP;
    AddressV = CLAMP;
};

sampler BackBuffer : register(s0);

//depth
texture depthMap;
sampler depthSampler = sampler_state
{
    Texture = (depthMap);
};

struct VertexShaderInput
{
    float3 Position : POSITION0;
    float2 texCoord : TEXCOORD0;
};

struct VertexShaderOutputToPS
{
    float2 texCoord : TEXCOORD0;
};
</pre>
<p>Those that I guess are not that obvious are Density to Decay and these relate the the lens flare part of the shader and control the number of texture samples to display, density of those samples etc..</p>
<p>So onto the lane flare function that is used in the shader to give the lens flare effect.</p>
<pre class="brush: csharp; title: ;">
float4 DoLenseFlare(float4 ScreenLightPosition,float2 texCoord,bool fwd)
{
    // Calculate vector from pixel to light source in screen space.
    float2 deltaTexCoord = (texCoord - ScreenLightPosition.xy);// Divide by number of samples and scale by control factor.
    deltaTexCoord *= 1.0f / 3 * Density;

    // Store initial sample.
    float3 color = 0;

    // Set up illumination decay factor.
    float illuminationDecay = 1.0f;

    for (int i = 0; i &amp;lt; 3 ; i++)
    {
        // Step sample location along ray.
        if(fwd)
            texCoord -= deltaTexCoord;
        else
            texCoord += deltaTexCoord;

        // Retrieve sample at new location.
        float3 sample = tex2D(Flare, texCoord);

        // Apply sample attenuation scale/decay factors.
        if(fwd)
            sample *= illuminationDecay * Weight;
        else
            sample *= illuminationDecay * Weight2;

        // Accumulate combined color.
        color += sample;

        // Update exponential decay factor.
        illuminationDecay *= Decay;
    }

    return float4(color,1);
}
</pre>
<p>I can take very little credit for this bit of the code, as I got it from GPU Game 3 Chapter 13 Volumetric Light Scattering as a Post Process, not exactly using it as it was intended, but is does the job I wanted here well enough <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So the pixel shader itself that pulls this all together looks like this</p>
<pre class="brush: csharp; title: ;">
float4 PixelShaderFunction(VertexShaderOutputToPS input) : COLOR0
{
    // Get the scene
    float4 col = tex2D(BackBuffer,input.texCoord);// Find the suns position in the world and map it to the screen space.
    float4 ScreenPosition = mul(lightPosition - cameraPosition,VP);
    float scale = ScreenPosition.z;
    ScreenPosition.xyz /= ScreenPosition.w;
    ScreenPosition.x = ScreenPosition.x/2.0f+0.5f;
    ScreenPosition.y = (-ScreenPosition.y/2.0f+0.5f);

    // get the depth from the depth map
    //float depthVal = 1- tex2D(depthSampler, input.texCoord).r;

    // Are we lokoing in the direction of the sun?
    if(ScreenPosition.w &gt; 0)
    {
        float2 coord;

        float size = SunSize / scale;

        float2 center = ScreenPosition.xy;

        coord = .5 - (input.texCoord - center) / size * .5;

        //if(depthVal &gt; ScreenPosition.z-.0003)
        col += (pow(tex2D(Flare,coord) * float4(Color,1),2) * lightIntensity) * 2;

        // Lens flare
        col += ((DoLenseFlare(ScreenPosition,input.texCoord,true) + DoLenseFlare(ScreenPosition,input.texCoord,false)) * float4(Color,1) * lightIntensity) * 5;
    }

    return col;
}
</pre>
<p>You will see in here that I have left in the code for detecting the depth of objects in the scene for sun culling and just commented it out, when you have a full release XNA 4.0 you will be able to create and pass in the depth map, but it’s not possible in the current CTP.</p>
<p>So what am I doing in the pixel shader, first off we grab the current scene’s color, I then get the position of the light in screen space by multiplying its position by the camera position and then doing the homogeneous divide (ScreenPosition.xyz / ScreenPosition.w) to get the position of the sun (see the Get2DCoords method below for my inspiration for this). Then, if we are looking in the direction of the sun (ScreenPosition.w &gt; 0) then we need to render the sun and or lens flare. I then calculate the size of the sun and find the tex coords required to get the texture from the Flare sampler and then add this with the sun color and raise it to the power of 2, this lightens the light bits and darkens the dark bits, this is then multiplied by the light intensity and the final values doubled again. Then we come to the lens flare, I call this twice: once for each direction of the flare (you will see in the clip there are two) and again tint this to the sun color and multiply by intensity.</p>
<p>Now please feel free to pick my dodgy math’s apart here I know I suck, but it is working and I have not thought much more abut it since writing it <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><strong>Game Code</strong></p>
<p>First thing we will do is set up a render target and and effect so we can apply our sun as a post process.</p>
<pre class="brush: csharp; title: ;">
RenderTarget2D rt;
Effect effect;
</pre>
<p>Also some way of representing the sun’s position, color intensity and size</p>
<pre class="brush: csharp; title: ;">
Vector3 sunPosition = new Vector3(100, 200, -1000);
Color sunColor = Color.White;
float sunIntensity = 1f;
float sunSunSize = 1500;
</pre>
<p>Now we have these variable lined up and ready to use we can initialize both the render target and the effect shader</p>
<pre class="brush: csharp; title: ;">
rt = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

effect = Content.Load&lt;Effect&gt;(&quot;Shaders/PostProcessing/Sun&quot;);
effect.Parameters[&quot;flare&quot;].SetValue(Content.Load&lt;Texture2D&gt;(&quot;Textures/PostProcessing/flare&quot;));
effect.Parameters[&quot;Color&quot;].SetValue(sunColor.ToVector3());
effect.Parameters[&quot;lightIntensity&quot;].SetValue(sunIntensity);
effect.Parameters[&quot;SunSize&quot;].SetValue(sunSunSize);
effect.Parameters[&quot;lightPosition&quot;].SetValue(sunPosition);
</pre>
<p>Now we need to make sure the shader/effect is updated with the required variables. So in our update method we set the following parameters</p>
<pre class="brush: csharp; title: ;">
effect.Parameters[&quot;VP&quot;].SetValue(camera.View * camera.Projection);
effect.Parameters[&quot;cameraPosition&quot;].SetValue(camera.Position);
//effect.Parameters[&quot;depthMap&quot;].SetValue(depthBuffer);
</pre>
<p>And now for the render, keep in mind that this is all done just for this sample, you will want to encapsulate all this in its own class deriving from DrawableGameComponent or in a post processing framework as shown in the link above.</p>
<pre class="brush: csharp; title: ;">
    GraphicsDevice.SetRenderTargets(rt);
    GraphicsDevice.Clear(&lt;Color.Black);
    base.Draw(gameTime);

    // Post Processing.
    GraphicsDevice.SetRenderTargets(null);

    GraphicsDevice.Textures[0] = rt;
    spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
    effect.Techniques[0].Passes[0].Apply();
    spriteBatch.Draw(rt, new Rectangle(0, 0, rt.Width, rt.Height), Color.White);
    spriteBatch.End();
</pre>
<p>So, we setup the render target, allow the scene to be drawn (nothing gets drawn in this sample), then we resolve the render target and then apply our effect to the newly captured render target.</p>
<p>As mentioned earlier I have a method I use to get screen coordinates from a 3D screen position, this method I am 99% sure I got (or at least the nuts and bolts of it) from Rocket Commander which was written by <a href="http://exdream.com/Games/Default.aspx?Game=RocketCommander&amp;Category=Open%20Source">Benjamin Nitsche</a></p>
<pre class="brush: csharp; title: ;">
public Vector2 Get2DCoords(Vector3 myPosition, Base3DCamera Camera)
{
    Matrix ViewProjectionMatrix = Camera.View * Camera.Projection;
    Vector4 result4 = Vector4.Transform(myPosition, ViewProjectionMatrix);

    if(result4.W &lt;= 0)
        return new Vector2(Camera.Viewport.Width, 0);

    Vector3 result = new Vector3(result4.X / result4.W, result4.Y / result4.W, result4.Z / result4.W);

    Vector2 retVal = new Vector2((int)Math.Round(+result.X * (Camera.Viewport.Width / 2)) + (Camera.Viewport.Width / 2), (int)Math.Round(-result.Y * (Camera.Viewport.Height / 2)) + (Camera.Viewport.Height / 2));

    return retVal;
}
</pre>
<p>As you can see it transforms the position by the ViewProjection matrix to then get the screen position if the result4.W &gt;= 0.</p>
<p><a href="http://www.sgtconker.com/Downloads/articles/RandomchaosSunPostProcess.zip">Download the sample project here</a><br />
Well that’s abut it, and this is my first post on Sgt Conker, hope it’s not my last one <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  Hope you find this useful, if not in it’s own right, then I hope it gives you some ideas for your own shaders…..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/04/article-sun-and-lens-flare-as-a-post-process/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Depth And Games</title>
		<link>http://www.sgtconker.com/2010/03/depth-and-games/</link>
		<comments>http://www.sgtconker.com/2010/03/depth-and-games/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 07:03:52 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Andy Dunn]]></category>
		<category><![CDATA[Chad Carter]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Chris G. Williams]]></category>
		<category><![CDATA[George W. Clingerman]]></category>
		<category><![CDATA[Glenn Wilson]]></category>
		<category><![CDATA[Iñaki Ayucar]]></category>
		<category><![CDATA[Joel Martinez]]></category>
		<category><![CDATA[John Sedlak]]></category>
		<category><![CDATA[Jon Watte]]></category>
		<category><![CDATA[Matt Pettino]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/depth-and-games/</guid>
		<description><![CDATA[Matt “Blitzkrieg” Pettino fights with the depth buffer and Charles “One” Humphrey flags bits in XNA.
Meanwhile, George W. “The Frayed Ends of Sanity” Clingerman stares at walls, not goats and Chris G. “Fade to Black” Williams says Good Night.
Glenn “Welcome Home (Sanitarium)” Wilson installs the Windows Phone Developer Tools CTP finally, Jon “Escape” Watte releases [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mynameismjp.wordpress.com/">Matt “Blitzkrieg” Pettino</a> <a title="For fun and precision!" href="http://mynameismjp.wordpress.com/2010/03/22/attack-of-the-depth-buffer/">fights with the depth buffer</a> and <a href="http://xna-uk.net/blogs/randomchaos/">Charles “One” Humphrey</a> <a title="Technically it is C#, but well…" href="http://xna-uk.net/blogs/randomchaos/archive/2010/03/24/bit-flags-in-xna.aspx">flags bits in XNA</a>.</p>
<p>Meanwhile, <a href="http://www.xnadevelopment.com/">George W. “The Frayed Ends of Sanity” Clingerman</a> <a title="He&#39;s Batman!" href="http://twitter.com/clingermangw/statuses/11006279926">stares at walls, not goats</a> and <a href="http://twitter.com/chrisgwilliams/">Chris G. “Fade to Black” Williams</a> <a title="…and Good Luck." href="http://twitter.com/chrisgwilliams/statuses/11023860310">says Good Night</a>.</p>
<p><a href="http://www.virtualrealm.com.au/">Glenn “Welcome Home (Sanitarium)” Wilson</a> <a title="…and takes pictures of the process!" href="http://www.virtualrealm.com.au/blogs/installing-the-windows-phone-developer-tools-ctp/">installs the Windows Phone Developer Tools CTP finally</a>, <a href="http://www.enchantedage.com/">Jon “Escape” Watte</a> <a title="Fixes two reported bugs!" href="http://twitter.com/jwatte/statuses/11020778763">releases a beta of kW X-port 1.4.5 for 3DS Max 2010</a> and in a desperate move <a href="http://thezbuffer.com/">Andy “Harvester of Sorrow” Dunn</a> <a title="He&#39;s the Optimistic MVP now :)" href="http://forums.xna.com/forums/p/50052/303144.aspx#303144">begs for common sense to be applied during peer review</a>. Following the lead of desperation, <a href="http://graphicdna.blogspot.com/">Iñaki “Whiplash” Ayucar</a> <a title="To duplicate is to lose." href="http://graphicdna.blogspot.com/2010/03/you-duplicating-you-wrong.html">fulminates against clones, strongly</a>.</p>
<p><a href="http://jsedlak.org/">John “Motorbreath” Sedlak</a> <a title="MVP Fashion" href="http://twitter.com/jsedlak/statuses/11043855917">has a new jacket</a>, <a title="Labeled!" href="http://twitpic.com/1auh24">with a back</a>, <a title="I still remembering playing the first one…" href="http://jsedlak.org/2010/03/25/running-settlers-7-in-windowed-mode/">plays games</a>, <a title="In LINQ and Lambdas" href="http://twitter.com/jsedlak/status/11067793612">writes cryptic code</a>. <a href="http://codecube.net/">Joel “Ride the Lightning” Martinez</a> <a title="Don&#39;t we all?" href="http://twitter.com/joelmartinez/status/11039511252">loves LINQ</a> and <a title="After G.O.D. follows G.O.M.?" href="http://twitter.com/joelmartinez/status/11046594144">threats to release a game</a>. Finally, <a href="http://xnaessentials.com/unleashed/">Chad “Hit the Lights” Carter</a> <a title="I never really understood why there need to be dedicated parent days (other than a pointless reason to drink lots of alcohol, semi accepted by society)" href="http://twitter.com/kewlniss/status/11118567522">is a happy daddy</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/depth-and-games/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jekyll And Hyde</title>
		<link>http://www.sgtconker.com/2010/03/jekyll-and-hyde/</link>
		<comments>http://www.sgtconker.com/2010/03/jekyll-and-hyde/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 05:11:30 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Andy Dunn]]></category>
		<category><![CDATA[Catalin Zima]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Chris G. Williams]]></category>
		<category><![CDATA[George W. Clingerman]]></category>
		<category><![CDATA[Jim Perry]]></category>
		<category><![CDATA[Joel Martinez]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/jekyll-and-hyde/</guid>
		<description><![CDATA[The week starts off with Catalin “Dan Briggs” Zima not being amused about the lack of support MS shows for Romania, followed by a Charles “Rex Rupert John George Robert Andrew Sinclair Earl of Mannoc” Humphreys in excitement, which finds an abrupt ending and Joel “Sandy Ricks” Martinez living on ancient hardware.
Ignoring the misery of [...]]]></description>
			<content:encoded><![CDATA[<p>The week starts off with <a href="http://www.catalinzima.com/">Catalin “Dan Briggs” Zima</a> <em>not</em> being amused about the <a title="What about Belgium? Some might want to know..." href="http://twitter.com/CatalinZima/status/10529501965">lack of support MS shows for Romania</a>, followed by a <a href="http://xna-uk.net/blogs/randomchaos">Charles “Rex Rupert John George Robert Andrew Sinclair Earl of Mannoc” Humphreys</a> <a title="A MVP excited about a new XNA Game Studio relase? NO WAI!!1" href="http://twitter.com/NemoKrad/status/10563041641">in excitement</a>, which <a title="Nope, Windows 7 x64 is good for XNA 4.0." href="http://twitter.com/NemoKrad/status/10564085474">finds an abrupt</a> <a title="Intentionally left blank." href="http://twitter.com/NemoKrad/status/10564102295">ending</a> and <a href="http://codecube.net/">Joel “Sandy Ricks” Martinez</a> <a title="The edge is on the other side" href="http://twitter.com/joelmartinez/status/10569110103">living on ancient hardware</a>.</p>
<p>Ignoring the misery of his fellow champs <a href="http://machaira.spaces.live.com/">Jim “Red Forman” Perry</a> mourns the loss of ancient arts, this time <a title="Forget sexy: Bring back the voodoo!" href="http://twitter.com/MachXGames/status/10587210548">The Art of Debugging</a>, which <a href="http://thezbuffer.com/">Andy “John Steed” Dunn</a> wonders <a title="Applying the art of debugging" href="http://twitter.com/The_Zman/status/10589613809">how to apply to the wandering to off-topic</a> <a title="And thus started the George W. Clingerman Gone Bad week" href="http://twitter.com/The_Zman/status/10589799137">Kinder on the forums</a>.</p>
<p>Meanwhile, <a href="http://www.xnadevelopment.com/">George W. “Dr. David Banner” Clingerman</a> goes mean. Yep, that’s right: the “group hug, peace and love” MVP is <a title="Quoting: You&#39;re nothing but a big cry baby. Boo hoo hoo. Guitar pick. Boo hoo. So mean. Buck up!" href="http://twitter.com/clingermangw/statuses/10588093839">the bully MVP now</a>. And then <a title="4 and counting; Or: Maybe the last time?" href="http://twitter.com/clingermangw/status/10597638858">he shows off</a>. At least he ain’t meaning his kids…</p>
<p><a title="Bad peers." href="http://twitter.com/chrisgwilliams/status/10591432672">Suffering from external mischief</a> <a href="http://twitter.com/chrisgwilliams/">Chris G. “Bosco Albert Baracus” Williams</a> is <a title="It also generates taxes. Lots." href="http://twitter.com/chrisgwilliams/status/10591573645">totally amazed and disappointed</a>. He’s also <a title="Upstairs? In the back? Will we see the Sergeant again?" href="http://twitter.com/chrisgwilliams/statuses/10606887630">giving strange hints about his whereabouts</a>…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/jekyll-and-hyde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shortly Replicated Pancakes</title>
		<link>http://www.sgtconker.com/2010/03/shortly-replicated-pancakes/</link>
		<comments>http://www.sgtconker.com/2010/03/shortly-replicated-pancakes/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 13:10:05 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Andy Dunn]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[Glenn Wilson]]></category>
		<category><![CDATA[Jim Perry]]></category>
		<category><![CDATA[Promit Roy]]></category>
		<category><![CDATA[Richard Fine]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/shortly-replicated-pancakes/</guid>
		<description><![CDATA[Jim “First Hand Knowledge” Perry writes XNA and Short Term Memory Loss.
Andy “Not Your Father” Dunn leaksprophesies information of XNA 10.5 (hint: it will take quite a few years and the arrival of the Sith Lords before anyone will get their hands onto it).
Richard “Pancakes” Fine works hard and eats unhealthy.
Charles “Picturesque” Humphrey does some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://machaira.spaces.live.com/">Jim “First Hand Knowledge” Perry</a> writes <a href="http://machaira.spaces.live.com/Blog/cns!C6A0309746469D9E!722.entry">XNA and Short Term Memory Loss</a>.</p>
<p><a href="http://thezbuffer.com/">Andy “Not Your Father” Dunn</a> <a href="http://twitter.com/The_Zman/statuses/9881603225"><strike>leaks</strike>prophesies information of XNA 10.5</a> (hint: it will take quite a few years and the arrival of the Sith Lords before anyone will get their hands onto it).</p>
<p><a href="http://www.gamedev.net/">Richard “Pancakes” Fine</a> <a href="http://twitter.com/Superpig/statuses/9900041567">works hard and eats unhealthy</a>.</p>
<p><a href="http://xna-uk.net/blogs/randomchaos">Charles “Picturesque” Humphrey</a> does some <a href="http://xna-uk.net/blogs/randomchaos/archive/2010/03/02/mvp-2010-summit.aspx">aftermath (if you count photo sharing as that) of the MVP 2010 Summit</a>.</p>
<p>If you’re in HR for your company Down Under and want to make one <a href="http://www.virtualrealm.com.au/">Glenn “Legendary Legend” Wilson</a> <a href="http://twitter.com/Mykre/statuses/9891897867">unredundant this is the time</a>!</p>
<p><a href="http://ventspace.wordpress.com/">Promit “Keep On Walking” Roy</a> <a href="http://www.youtube.com/watch?v=AKIN4tfcbVU">shares progress of BioReplicant</a>, “a completely reactive procedural animation system for use in video games”.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/shortly-replicated-pancakes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buzz And Contact</title>
		<link>http://www.sgtconker.com/2010/02/buzz-and-contact/</link>
		<comments>http://www.sgtconker.com/2010/02/buzz-and-contact/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 15:29:56 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[MVP Watch]]></category>
		<category><![CDATA[Andy Dunn]]></category>
		<category><![CDATA[Charles Humphrey]]></category>
		<category><![CDATA[George W. Clingerman]]></category>
		<category><![CDATA[Jim Perry]]></category>
		<category><![CDATA[John Sedlak]]></category>
		<category><![CDATA[Richard Thompson]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/02/buzz-and-contact/</guid>
		<description><![CDATA[SCENE XIX
Twitter.
Enter Richard “Philosopher” Thompson.
Richard. Having the Blues http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.11-Having_the_Blues.jpg
Richard. A Hole in One http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.10-A_Hole_in_One.jpg
Richard. &#34;With collections, the Null Object Pattern is free--you just return an empty collection.&#34;
Exeunt.
Enter John “Integrator” Sedlak.
John. Wow. I actually enjoy reading the CCO forums now!!
Enter Jim “Conservator” Perry.
Jim. @jsedlak so you're a masochist?!? 8\
John. @NemoKrad NICE! I am going to look [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><em>SCENE XIX</em></p>
<p align="center"><em>Twitter.</em></p>
<p align="center"><em>Enter <a href="http://twitter.com/legalizeadulthd/">Richard “Philosopher” Thompson</a>.</em></p>
<p align="left"><em><a href="http://twitter.com/legalizeadulthd/status/8888846960">Richard</a>.</em> Having the Blues <a href="http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.11-Having_the_Blues.jpg">http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.11-Having_the_Blues.jpg</a></p>
<p align="left"><em><a href="http://twitter.com/legalizeadulthd/status/8888856040">Richard</a></em>. A Hole in One <a href="http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.10-A_Hole_in_One.jpg">http://www.xmission.com/~legalize/fractals/fotd/2008/10/2008.10.10-A_Hole_in_One.jpg</a></p>
<p align="left"><em><a href="http://twitter.com/legalizeadulthd/status/8890307784">Richard</a>.</em> &quot;With collections, the Null Object Pattern is free--you just return an empty collection.&quot;</p>
<p align="center"><em>Exeunt.</em></p>
<p align="center"><em>Enter <a href="http://twitter.com/jsedlak/">John “Integrator” Sedlak</a>.</em></p>
<p align="left"><em><a href="http://twitter.com/jsedlak/status/8896087913">John</a>.</em> Wow. I actually enjoy reading the CCO forums now!!</p>
<p align="center"><em>Enter <a href="http://twitter.com/MachXGames/">Jim “Conservator” Perry</a>.</em></p>
<p align="left"><em><a href="http://twitter.com/MachXGames/status/8901260431">Jim</a>.</em> @<a href="http://twitter.com/jsedlak">jsedlak</a> so you're a masochist?!? 8\</p>
<p align="left"><em><a href="http://twitter.com/jsedlak/status/8901296359">John</a>.</em> @<a href="http://twitter.com/NemoKrad">NemoKrad</a> NICE! I am going to look at that tomorrow. Can I integrate it into FGF? <a href="http://jsedlak.org/fgf">http://jsedlak.org/fgf</a></p>
<p align="center"><em>Exeunt John and Jim.</em></p>
<p align="center"><em>Enter <a href="http://twitter.com/clingermangw/">George W. “Reflector” Clingerman</a>.</em></p>
<p align="left"><em><a href="http://twitter.com/clingermangw/statuses/8904333776">George</a>.</em> At some point I really should do a Kissy Poo post-mortem. Things we did right, but there's quite a few things I wish we had done differently</p>
<p align="center"><em>Enter <a href="http://twitter.com/The_Zman/">Andy “Instructor” Dunn</a>.</em></p>
<p align="left"><em><a href="http://twitter.com/The_Zman/statuses/8904454013">Andy</a></em>. @<a href="http://twitter.com/Kitt1e2009">Kitt1e2009</a> : Unless he has a 'scale to fit' then yes… for the icons on the right mainly (assuming the red box is correclty <em>[sic]</em> positioned)</p>
<p align="center"><em>Exit.</em></p>
<p align="left"><em><a href="http://twitter.com/clingermangw/status/8904637974">George</a></em>. @<a href="http://twitter.com/The_Zman">The_Zman</a> @<a href="http://twitter.com/Kitt1e2009">Kitt1e2009</a> &quot;assuming the red box is correctly positioned&quot; is why I suggest you only fail if you're actually experiencing it</p>
<p align="center"><em>Exit.</em></p>
<p style="margin-top: 2em" align="center"><em>SCENE XX</em></p>
<p align="center"><a href="http://xna-uk.net/"><em>The XNA-UK Blog</em></a><em>.</em></p>
<p align="center"><em>Enter </em><a href="http://xna-uk.net/blogs/randomchaos/archive/2010/02/10/xna-and-windows-7-multi-touch.aspx"><em>Charles “Responder” Humphrey</em></a><em>.</em></p>
<p><em>Charles.</em> I am pretty sure, that like me you are more than capable of scanning the web for snippets of info on how to do this, well I thought, to save you the time and effort I’ll put up a simple how-to here.</p>
<p align="center"><em>Explain the code.</em></p>
<p><em>Charles.</em> And that’s about it, hope you find it useful. The solution for this post can be found <a href="http://xna-uk.net/files/folders/randomchaos/entry3054.aspx">here</a>. As ever C&amp;C welcome.</p>
<p align="center"><em>Exit.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/02/buzz-and-contact/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

