<?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; Graphics</title>
	<atom:link href="http://www.sgtconker.com/tag/graphics/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>Catalin on 2D Skeletal Animations</title>
		<link>http://www.sgtconker.com/2011/06/catalin-on-2d-skeletal-animations/</link>
		<comments>http://www.sgtconker.com/2011/06/catalin-on-2d-skeletal-animations/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 19:15:16 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Catalin Zima]]></category>
		<category><![CDATA[Skeletons]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2011/06/catalin-on-2d-skeletal-animations/</guid>
		<description><![CDATA[Catalin “Too Proud To Self-promote” Zima (you might know him as our local XNA MVP Captain ZSquare) has a nice write-up of 2D Skeletal Animations over at his blog. So, if you ever wondered what the benefits of skeletal animations in the 2D world as compared to our beloved sprite sheets are, his post would [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.catalinzima.com/">Catalin “Too Proud To Self-promote” Zima</a> (you might know him as our local XNA MVP Captain ZSquare) has a nice write-up of <a href="http://www.catalinzima.com/2011/06/2d-skeletal-animations/">2D Skeletal Animations over at his blog</a>. So, if you ever wondered what the benefits of skeletal animations in the 2D world as compared to our beloved sprite sheets are, <a href="http://www.catalinzima.com/2011/06/2d-skeletal-animations/">his post would be your starting point</a> to explore this very topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2011/06/catalin-on-2d-skeletal-animations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screen-space deformations in XNA for Windows Phone 7</title>
		<link>http://www.sgtconker.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/</link>
		<comments>http://www.sgtconker.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 21:56:40 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/</guid>
		<description><![CDATA[Captain ZSquare shares his technique to do screen-space deformations on Windows Phone 7. Introduces Catalin:
Working on our games, we came across the need to do some screen-space deformations for all sorts of special effects like explosions, ‘drunk filter’, warp effects and other similar stuff. But since we’re targeting Windows Phone 7, we don’t have access [...]]]></description>
			<content:encoded><![CDATA[<p>Captain ZSquare shares his technique to do <a href="http://www.amusedsloth.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/">screen-space deformations on Windows Phone 7</a>. Introduces Catalin:</p>
<blockquote cite="http://www.amusedsloth.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/"><p>Working on our games, we came across the need to do some screen-space deformations for all sorts of special effects like explosions, ‘drunk filter’, warp effects and other similar stuff. But since we’re targeting Windows Phone 7, we don’t have access to any custom shaders (which is a bummer), so we had to be creative. In the end, the solution turned out to be rather simple, and the performance is good enough (if you don’t go overboard with the effects, of course).</p>
</blockquote>
<p>See <a href="http://www.amusedsloth.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/">the post for screen shoots <em>and</em> code</a>!</p>
<p><em>Lets see if Captain ZSquare <a href="http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass/">reposts</a> this one <a href="http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass-2/">with a screen shoot</a>, too <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2011/01/screen-space-deformations-in-xna-for-windows-phone-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XNA 4.0 Light Pre-Pass</title>
		<link>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass-2/</link>
		<comments>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass-2/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 09:08:38 +0000</pubDate>
		<dc:creator>Captain ZSquare</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Coluna]]></category>
		<category><![CDATA[light pre pass]]></category>
		<category><![CDATA[Rendering]]></category>
		<category><![CDATA[XNA 4.0]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1947</guid>
		<description><![CDATA[Jorge Coluna posted an article on his site about implementing the Light Pre-Pass technique for rendering in XNA 4.0

Read all about it here.
]]></description>
			<content:encoded><![CDATA[<p>Jorge Coluna posted an article on<a href="http://jcoluna.wordpress.com/"> his site</a> about implementing the Light Pre-Pass technique for rendering in XNA 4.0</p>
<p><a href="http://jcoluna.wordpress.com/2011/01/18/xna-4-0-light-pre-pass/"><img class="alignnone" title="Light Pre-Pass in XNA 4.0" src="http://jcoluna.files.wordpress.com/2011/01/shot-lpp-11.jpg" alt="Light Pre-Pass in XNA 4.0" width="467" height="275" /></a></p>
<p>Read all about it <a href="http://jcoluna.wordpress.com/2011/01/18/xna-4-0-light-pre-pass/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA 4.0 Light Pre-Pass</title>
		<link>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass/</link>
		<comments>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 05:42:22 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[light pre pass]]></category>
		<category><![CDATA[VoteForGeorge]]></category>
		<category><![CDATA[XNA 4.0]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass/</guid>
		<description><![CDATA[Jorge Coluna shares the code and an article of his Light Pre-Pass technique for XNA 4.0. Says the Jorge:
The discussion between pros and cons of different techniques for real-time lighting has been running for years. Forward rendering, deferred shading and light pre-pass are some of the most famous techniques nowadays. Their definitions and variations can [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jcoluna.wordpress.com/">Jorge Coluna</a> shares the code and an article of his <a href="http://jcoluna.wordpress.com/2011/01/18/xna-4-0-light-pre-pass/">Light Pre-Pass technique</a> for XNA 4.0. Says the Jorge:</p>
<blockquote cite="http://jcoluna.wordpress.com/2011/01/18/xna-4-0-light-pre-pass/"><p>The discussion between pros and cons of different techniques for real-time lighting has been running for years. Forward rendering, <a href="http://en.wikipedia.org/wiki/Deferred_shading">deferred shading</a> and <a href="http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass-renderer.html">light pre-pass</a> are some of the most famous techniques nowadays. Their definitions and variations can be found with a simple search on internet, with all the most complex mathematics, notations and formulas possible. Therefore I will not focus on this.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2011/01/xna-4-0-light-pre-pass/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Whoa&#8230; long time no see</title>
		<link>http://www.sgtconker.com/2010/11/whoa-long-time-no-see/</link>
		<comments>http://www.sgtconker.com/2010/11/whoa-long-time-no-see/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 20:33:47 +0000</pubDate>
		<dc:creator>Captain ZSquare</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Bob Taco Ind]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Hargreaves]]></category>
		<category><![CDATA[The Shawn]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1878</guid>
		<description><![CDATA[Sorry for the long absence  
Anyway, here's some news:
Miscellany Tips for Working With a WP7 Device for the First Time, by Michael B. McLaughlin
Compressed GPU data formats, by The Shawn
Viewing Windows Phone 7 Marketplace on the simulator, by David Amador
]]></description>
			<content:encoded><![CDATA[<p>Sorry for the long absence <img src='http://www.sgtconker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, here's some news:</p>
<p><a href="http://geekswithblogs.net/mikebmcl/archive/2010/11/18/miscellany-tips-for-working-with-a-wp7-device-for-the.aspx">Miscellany Tips for Working With a WP7 Device for the First Time</a>, by Michael B. McLaughlin</p>
<p><a href="http://blogs.msdn.com/b/shawnhar/archive/2010/11/19/compressed-gpu-data-formats.aspx">Compressed GPU data formats</a>, by The Shawn</p>
<p><a href="http://www.david-amador.com/2010/11/viewing-windows-phone-7-marketplace-on-the-simulator/">Viewing Windows Phone 7 Marketplace on the simulator</a>, by David Amador</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/11/whoa-long-time-no-see/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA Tile Engine Base Solution for WP7</title>
		<link>http://www.sgtconker.com/2010/10/xna-tile-engine-base-solution-for-wp7/</link>
		<comments>http://www.sgtconker.com/2010/10/xna-tile-engine-base-solution-for-wp7/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 14:39:41 +0000</pubDate>
		<dc:creator>Sgt. Conker</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Gareth Williams]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Tile Engine]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/?p=1822</guid>
		<description><![CDATA[Gareth Williams has posted news of his Tile Engine solution for XNA which runs on Windows Phone 7.

And a handy list of all the features of the solution:

Suitable for side-on and top-down games
Good for platformers, RPGs, shooters, racers, adventures - anything that needs tiles!
Works in landscape or portrait with one line change.
Built on the Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Gareth Williams has posted news of his Tile Engine solution for XNA which runs on Windows Phone 7.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/YtHxYnejTwQ?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/YtHxYnejTwQ?fs=1&amp;hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>And a handy list of all the features of the solution:</p>
<ul>
<li>Suitable for side-on and top-down games</li>
<li>Good for platformers, RPGs, shooters, racers, adventures - anything that needs tiles!</li>
<li>Works in landscape or portrait with one line change.</li>
<li>Built on the Windows Phone 7 XNA Gamestate Management engine sample.</li>
<li>Uses Nick Gravelyn's content pipeline extension for the "Tiled" editor.</li>
<li>Simple but flexible camera class that clamps to the map boundaries.</li>
<li>Draw the whole map at once, or one layer at a time for flexibility.</li>
<li>Parallax scrolling simply by adding a couple of properties to a layer in Tiled.</li>
<li>An overload to draw a layer as "shadows" by drawing offset+black+semi-transparent.</li>
<li>Per-pixel colour-based collision detection on specified layers/tilesets.</li>
</ul>
<p>There's a link to the sample project on his blog, please read the rest of this post along with trying out the sample.<br />
<a href="http://fatsweb.blogspot.com/2010/09/phone-7-xna-tile-engine-base-solution.html?spref=tw">Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/10/xna-tile-engine-base-solution-for-wp7/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>16</slash:comments>
		</item>
		<item>
		<title>Placeholder in Games</title>
		<link>http://www.sgtconker.com/2010/03/placeholder-in-games/</link>
		<comments>http://www.sgtconker.com/2010/03/placeholder-in-games/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 09:48:57 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/placeholder-in-games/</guid>
		<description><![CDATA[Barnaby Smith shares his thoughts about using placeholder assets during the development of games:
Creation and use of placeholders, whether levels, 3d models, sprites or sounds, has a number of advantages when developing computer games. In this article I discuss some aspects of the use of placeholders in games.

]]></description>
			<content:encoded><![CDATA[<p><a href="http://xna-uk.net/blogs/mvi/default.aspx">Barnaby Smith</a> shares his thoughts about <a href="http://xna-uk.net/blogs/mvi/archive/2010/03/28/placeholders-in-games.aspx">using placeholder assets</a> during the development of games:</p>
<blockquote cite="http://xna-uk.net/blogs/mvi/archive/2010/03/28/placeholders-in-games.aspx"><p>Creation and use of placeholders, whether levels, 3d models, sprites or sounds, has a number of advantages when developing computer games. In this article I discuss some aspects of the use of placeholders in games.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/placeholder-in-games/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Render Target Changes in XNA Game Studio 4.0</title>
		<link>http://www.sgtconker.com/2010/03/render-target-changes-in-xna-game-studio-4-0/</link>
		<comments>http://www.sgtconker.com/2010/03/render-target-changes-in-xna-game-studio-4-0/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 01:43:45 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[RenderTarget]]></category>
		<category><![CDATA[XNA 4.0]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/render-target-changes-in-xna-game-studio-4-0/</guid>
		<description><![CDATA[The Shawn of Hargreaves details the changes to the render target API in XNA Framework 4.0. The high level summary of these changes are:

RenderTarget2D inherits from Texture2D and RenderTargetCube from TextureCube to properly denote the Is-a in the API (no more RenderTarget*.GetTexture()) 
Multiple render targets are set at once without explicitly specifying its index and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.msdn.com/shawnhar/">The Shawn of Hargreaves</a> details the <a href="http://blogs.msdn.com/shawnhar/archive/2010/03/26/rendertarget-changes-in-xna-game-studio-4-0.aspx">changes to the render target API in XNA Framework 4.0</a>. The high level summary of these changes are:</p>
<ul>
<li><code>RenderTarget2D</code> inherits from <code>Texture2D</code> and <code>RenderTargetCube</code> from <code>TextureCube</code> to properly denote the Is-a in the API (no more <code>RenderTarget*.GetTexture()</code>) </li>
<li>Multiple render targets are set at once without explicitly specifying its index and all previous set render targets are unset automatically</li>
<li>An optional depth buffer for a render target is now a property of the render target itself, which might be shared across multiple render targets if certain conditions are met </li>
</ul>
<p>For the motivation and details of these changes see <a href="http://blogs.msdn.com/shawnhar/archive/2010/03/26/rendertarget-changes-in-xna-game-studio-4-0.aspx">Rendertarget changes in XNA Game Studio 4.0</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/render-target-changes-in-xna-game-studio-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Resolution Independent Rendering in 2D</title>
		<link>http://www.sgtconker.com/2010/03/howto-resolution-independent-rendering-in-2d/</link>
		<comments>http://www.sgtconker.com/2010/03/howto-resolution-independent-rendering-in-2d/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 23:28:22 +0000</pubDate>
		<dc:creator>Captain boki</dc:creator>
				<category><![CDATA[2D]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.sgtconker.com/2010/03/howto-resolution-independent-rendering-in-2d/</guid>
		<description><![CDATA[David Amador shares his code to work with a fixed resolution on Windows without having to manage the placement of your renderables yourself. Sez David:
Independent Resolution Rendering?? What’s this all about?
Basically a way of not caring what you resolution is. Ever had Gui elements misplaced because you changed the resolution? Or getting out of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.david-amador.com/">David Amador</a> <a href="http://www.david-amador.com/2010/03/xna-2d-independent-resolution-rendering/">shares his code to work with a fixed resolution on Windows</a> without having to manage the placement of your renderables yourself. Sez David:</p>
<blockquote cite="http://www.david-amador.com/2010/03/xna-2d-independent-resolution-rendering/"><p>Independent Resolution Rendering?? What’s this all about?</p>
<p>Basically a way of not caring what you resolution is. Ever had Gui elements misplaced because you changed the resolution? Or getting out of the screen?</p>
<p>If you are doing a game on Xna just for Xbox360 you can basically use a 1280×720 base resolution and the Xbox will scale the game for you making the proper Letterbox.</p>
<p>But what about on Windows? Or if you use a different resolution on the Xbox? You have to manage that yourself.</p>
<p>I’ve made a small example on how to achieve this.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sgtconker.com/2010/03/howto-resolution-independent-rendering-in-2d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

