<?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>MQuandt.Blog &#187; Tips</title>
	<atom:link href="http://mquandt.com/blog/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://mquandt.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 12:16:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='mquandt.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>IC Game Design &#8211; A Key Tip for Success</title>
		<link>http://mquandt.com/blog/2011/03/ic-game-design-a-key-tip-for-success/</link>
		<comments>http://mquandt.com/blog/2011/03/ic-game-design-a-key-tip-for-success/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 04:18:20 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[game design]]></category>
		<category><![CDATA[imagine cup]]></category>
		<category><![CDATA[imaging cup game design]]></category>

		<guid isPermaLink="false">http://mquandt.com/blog/?p=126</guid>
		<description><![CDATA[Recently I have had the pleasure of helping to judge the entries for the 2011 Imagine Cup Game Design competition. The quality of some of the entries assigned to me was quite high, however there were some issues that prevented me from experiencing some of the games as intended. So I decided to write this &#8230; <a href="http://mquandt.com/blog/2011/03/ic-game-design-a-key-tip-for-success/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img style="background-image: none; border-right-width: 0px; margin: 0px 5px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="emulator" border="0" alt="emulator" align="left" src="http://mquandt.com/blog/wp-content/uploads/2011/03/emulator.png" width="200" height="354" />Recently I have had the pleasure of helping to judge the entries for the 2011 Imagine Cup Game Design competition. The quality of some of the entries assigned to me was quite high, however there were some issues that prevented me from experiencing some of the games as intended. So I decided to write this post to outline how to ensure the judge gets the best experience possible, and consequently help your chances of making it to the finals.</p>
<p>When judging I attempt the following:</p>
<ol>
<ol>
<ol>
<li>
<div align="left">Test on Phone (HTC Mozart) </div>
</li>
<li>
<div align="left">If that fails, Test in Emulator </div>
</li>
<li>
<div align="left">If that fails, Watch Video </div>
</li>
</ol>
</ol>
</ol>
<p>Now obviously the further I go along that list, the less you will receive in the polish section, and that varies based on which round it is, and when the game fails. (A game that times out during first load will lose more than a game that randomly crashes mid-game, my phone isn’t wildly different from most other phones out at the moment)</p>
<p>Now this is all well and fine you say, it works on my phone and unexpected crashes can occur early on in development. Sure, no problem, I can always test in the emulator, except of course if you put the game into the Games Hub. Whilst that will work on my phone, this unfortunately does not work on the stock emulator, which lacks the games hub. That means that it is impossible for me to test your game, and you will lose quite a bit more as I have to try and figure out the scores based off your gameplay video submission. It is after all impossible to get a good feel for the fun in a game from just a video. (or am I too jaded after many trailers that hype up modern games past their real level of fun?)</p>
<p>So please, if you’re developing a game for the competition, <strong>do *NOT* put your game into the games hub</strong>, because your game might crash, and I can only play (and judge) what is accessible.</p>
]]></content:encoded>
			<wfw:commentRss>http://mquandt.com/blog/2011/03/ic-game-design-a-key-tip-for-success/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA Tip #1</title>
		<link>http://mquandt.com/blog/2011/01/xna-tip-1/</link>
		<comments>http://mquandt.com/blog/2011/01/xna-tip-1/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 14:15:13 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[alpha blending]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://mquandt.com/blog/2011/01/xna-tip-1/</guid>
		<description><![CDATA[This is the first in what will probably be a random series of small posts about tips and tricks, and other notes about xna. When implementing the light pre-pass algorithm in XNA 4.0, I found that the alpha channel was messing around with my intermediate render targets. To resolve this, you need to create a &#8230; <a href="http://mquandt.com/blog/2011/01/xna-tip-1/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><i>This is the first in what will probably be a random series of small posts about tips and tricks, and other notes about xna.</i></p>
<p>When implementing the light pre-pass algorithm in XNA 4.0, I found that the alpha channel was messing around with my intermediate render targets.    <br />To resolve this, you need to create a custom blend state object (cache it) with the colour and alpha destination and blend states set to BlendState.One.</p>
<p>This should prevent any modulation based on the alpha value in a texture when sampling.</p>
<p>*<strong>Edit</strong>* Small code sample:</p>
<pre class="brush: csharp;">var _alphaBlend = new BlendState()
            {
                AlphaDestinationBlend = Blend.One,
                AlphaSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
                ColorSourceBlend = Blend.One
            };</pre>
]]></content:encoded>
			<wfw:commentRss>http://mquandt.com/blog/2011/01/xna-tip-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reconstructing Position from Depth for Fullscreen Quads</title>
		<link>http://mquandt.com/blog/2010/06/reconstructing-position-from-depth-for-fullscreen-quads/</link>
		<comments>http://mquandt.com/blog/2010/06/reconstructing-position-from-depth-for-fullscreen-quads/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 02:56:35 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[depth]]></category>
		<category><![CDATA[frustum ray]]></category>
		<category><![CDATA[techniques]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://mquandt.com/blog/?p=108</guid>
		<description><![CDATA[Recently I found an issue with an older article of mine that covered this topic, so I pulled it down until I could find the time to understand and fix the issue. After a bit of work I have fixed it and present this refresh. The key to deferred rendering and other techniques is the &#8230; <a href="http://mquandt.com/blog/2010/06/reconstructing-position-from-depth-for-fullscreen-quads/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I found an issue with an older article of mine that covered this topic, so I pulled it down until I could find the time to understand and fix the issue. After a bit of work I have fixed it and present this refresh.</p>
<p>The key to deferred rendering and other techniques is the ability to use a depth map to store world position. As we know a depth map consists of floating point values (optimally) and so normally we would use those values with our Clip Space coordinates and the Inverse of the ViewProjection matrix to get the position in World Space.</p>
<p>However there is another way to do this, and the big benefit is that it does not require a matrix multiplication to do so.</p>
<p>Presented by Crytek during a presentation on Atmospheric Scattering, this method uses just a Multiply + Add to get the position in World Space from our depth value at that point. To do this we need to get the far view frustum corners, in View Space, and pass them to the shader.</p>
<p>  <span id="more-108"></span><br />
<h3>Getting the Corners</h3>
<p>This is easily done in XNA through the BoundingFrustum.GetCorners() method. Note that we only need the far corners, so we can take the last 4 in the 8 element array, and we also need these corners in View space, so be sure to transform them by the View matrix before you pass them through.</p>
<pre class="brush: csharp;">private void getFrustumCorners(out Vector3[] corners)
{
    corners = new Vector3[4];

    Vector3[] temp = CurrentCamera.Frustum.GetCorners();
    for (int i = 0; i &lt; 4; i++)
    {
        corners[i] = Vector3.Transform(temp[i + 4], CurrentCamera.View);
    }
}</pre>
<p>Since we are in the CPU/XNA code, be sure to also pass the depth of the far clip plane, and the camera’s World matrix. (Simply invert the View matrix if you do not already have a World matrix)</p>
<h3>Writing out Depth</h3>
<p>Now for some shader code! First in the depth shader, you need to change how you write out the depth value, instead we take the Linear View Space depth, which means that we need to get the Z value from Position * World * View rather than Position * World * View * Projection.</p>
<pre class="brush: cpp;">float4x4 wv = mul( World, View );
float4 posVS = mul( pos, wv );

output.Position = mul( posVS, Projection );
output.Depth = posVS.z;</pre>
<p>Then in the pixel shader, take this depth value, negate it and divide it by the Far Clipping plane.</p>
<pre class="brush: cpp;">output.Depth = 1.0f - ( -depth / FarClip );</pre>
<p>Now when you want to reconstruct this, we need to find the correct frustum corner inside the vertex shader. (Note: This code only applies if you are rendering a fullscreen quad)</p>
<h3>Preparing and Choosing the Right Corner</h3>
<p>The best way to do this is to pass along the array index as a 3rd value with your texture coordinates. If you do not want to modify the vertex type, you can also apply some maths to determine the right index.</p>
<p>For brevity I will assume that the index is provided with the texture coordinates.</p>
<p>Take that ray and multiply it by the camera World matrix, to move the ray into World space, then pass it to the pixel shader.</p>
<pre class="brush: cpp;">output.FrustRay = mul( FSQ_GetFrustumRay( tcri.z ), CamWorld );</pre>
<h3>Getting the Position</h3>
<p>Now that you have the ray, simply sample the depth texture for the depth value, and multiply it by the ray. Then take that and add it to the camera position to get the point in world space. (Rather than just a direction)</p>
<pre class="brush: cpp;">float depth = 1.0f - tex2D( depthSampler, tc ).x;
float3 pos = CamPosition + depth * frustRay;</pre>
<p>Now you have your position!</p>
<p>I will include the technique to do the same thing with arbitrary world geometry when I write an article on Point Lights or Spotlights. At the moment I am working on implementing shadows, and probably won’t touch those topics until I solve some pressing issues.</p>
<h3>Final Notes</h3>
<p>Here is a code sample for passing the index as a part of the texture coordinate value.</p>
<p>&#160;</p>
<pre class="brush: csharp;">private struct VertexPositionTexCoordRayIndex
{
    private Vector3 position;
    public Vector3 Position
    {
        get { return position; }
        set { position = value; }
    }

    private Vector3 texCoordRayIndex;
    public Vector3 TexCoordRayIndex
    {
        get { return texCoordRayIndex; }
        set { texCoordRayIndex = value; }
    }

    public static int SizeInBytes { get { return sizeof(float) * 6; } }

    public static readonly VertexElement[] VertexElements =
        new VertexElement[] {
            new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
            new VertexElement(0, sizeof(float)*3, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0)
        };

    public VertexPositionTexCoordRayIndex(Vector3 position, Vector3 texcoordRayindex)
    {
        this.position = position;
        this.texCoordRayIndex = texcoordRayindex;
    }
}</pre>
<pre class="brush: csharp;">VertexPositionTexCoordRayIndex[] verts = new VertexPositionTexCoordRayIndex[4];
verts[0] = new VertexPositionTexCoordRayIndex(new Vector3(-1, 1, 1), new Vector3(0, 0, 0));
verts[1] = new VertexPositionTexCoordRayIndex(new Vector3(1, 1, 1), new Vector3(1, 0, 1));
verts[2] = new VertexPositionTexCoordRayIndex(new Vector3(-1, -1, 1), new Vector3(0, 1, 3));
verts[3] = new VertexPositionTexCoordRayIndex(new Vector3(1, -1, 1), new Vector3(1, 1, 2));</pre>
<p>&#160;</p>
<p>Remember that XNA provides the corners in a different order to just 1,2,3,4, so we can explicitly pass the correct index for the vertex we are working with here, and it will be chosen correctly in the shader.</p>
]]></content:encoded>
			<wfw:commentRss>http://mquandt.com/blog/2010/06/reconstructing-position-from-depth-for-fullscreen-quads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autodesk Student Subscriptions [Freebies]</title>
		<link>http://mquandt.com/blog/2010/01/autodesk-student-subscriptions-freebies/</link>
		<comments>http://mquandt.com/blog/2010/01/autodesk-student-subscriptions-freebies/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 12:26:56 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[3ds max]]></category>
		<category><![CDATA[autodesk]]></category>
		<category><![CDATA[maya]]></category>

		<guid isPermaLink="false">http://mquandt.com/blog/2010/01/autodesk-student-subscriptions-freebies/</guid>
		<description><![CDATA[I know that many of you will want to make use of either Blender or the nice free version of Softimage (Previously XSI) on the Creators Club website, however for those interested in expanding their skill set, perhaps with the intention of entering the industry, getting access to 3ds Max or Maya can be quite &#8230; <a href="http://mquandt.com/blog/2010/01/autodesk-student-subscriptions-freebies/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know that many of you will want to make use of either Blender or the nice free version of Softimage (Previously XSI) on the Creators Club website, however for those interested in expanding their skill set, perhaps with the intention of entering the industry, getting access to 3ds Max or Maya can be quite hard to do.* (legitimately)</p>
<p>I recently found that if you are a student and have an email address with your institution (.edu) then you can get access to licenses for Max, Maya, even AutoCAD and Revit for free using the Autodesk Student subscription.</p>
<p>Just go to <a href="http://students.autodesk.com">http://students.autodesk.com</a> to see if you qualify and register.</p>
<p><em>* I am not implying that 3ds Max + Maya are the only tools the industry uses, however they are the focus of this post.</em></p>
<p>Side Note: There are way too many versions of AutoCAD.</p>
]]></content:encoded>
			<wfw:commentRss>http://mquandt.com/blog/2010/01/autodesk-student-subscriptions-freebies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

