<?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>Aaron Oneal&#039;s Blog</title>
	<atom:link href="http://aarononeal.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://aarononeal.info</link>
	<description>In the Age of the Digerati</description>
	<lastBuildDate>Tue, 22 May 2012 18:55:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Silverlight 5 RC New XNA Features</title>
		<link>http://aarononeal.info/silverlight-5-rc-new-xna-features/</link>
		<comments>http://aarononeal.info/silverlight-5-rc-new-xna-features/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 06:02:06 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=203</guid>
		<description><![CDATA[The Silverilght 5 RC brings with it some new features for 3D and XNA – Effects, RenderTargets, Multisample Antialiasing, and more. We’ll be updating the online content soon, but in...]]></description>
				<content:encoded><![CDATA[<p>The Silverilght 5 RC brings with it some new features for 3D and XNA – Effects, RenderTargets, Multisample Antialiasing, and more. We’ll be updating the online content soon, but in the meantime, David Catuhe has written up the key changes here:</p>
<p><a title="http://blogs.msdn.com/b/eternalcoding/archive/2011/09/01/silverlight-5-rc-what-s-new-in-the-3d-world.aspx" href="http://blogs.msdn.com/b/eternalcoding/archive/2011/09/01/silverlight-5-rc-what-s-new-in-the-3d-world.aspx">http://blogs.msdn.com/b/eternalcoding/archive/2011/09/01/silverlight-5-rc-what-s-new-in-the-3d-world.aspx</a></p>
<p><a href="http://aarononeal.info/wp-content/uploads/2011/09/SL5RCBabylon.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SL5RCBabylon" border="0" alt="SL5RCBabylon" src="http://aarononeal.info/wp-content/uploads/2011/09/SL5RCBabylon_thumb.png" width="534" height="437" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/silverlight-5-rc-new-xna-features/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Load a 3D Model in Silverlight 5 Beta</title>
		<link>http://aarononeal.info/load-a-3d-model-in-silverlight-5-beta/</link>
		<comments>http://aarononeal.info/load-a-3d-model-in-silverlight-5-beta/#comments</comments>
		<pubDate>Mon, 09 May 2011 18:02:03 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=186</guid>
		<description><![CDATA[Silverlight 3D Model Importer Project If you’re looking for a quick way to get a 3D model loaded using the Silverlight 5 Beta, check out the Silverlight 3D Model Importer...]]></description>
				<content:encoded><![CDATA[<p><strong><a href="http://aarononeal.info/wp-content/uploads/2011/05/Lizard.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="Lizard" src="http://aarononeal.info/wp-content/uploads/2011/05/Lizard_thumb.png" alt="Lizard" width="242" height="202" border="0" /></a></strong></p>
<p><strong>Silverlight 3D Model Importer Project</strong></p>
<p>If you’re looking for a quick way to get a 3D model loaded using the Silverlight 5 Beta, check out the <a href="http://sl3dmi.codeplex.com/" target="_blank">Silverlight 3D Model Importer</a> project on CodePlex by <a href="http://www.simonferquel.net/blog/" target="_blank">Simon Ferquel</a>. You can export content from an <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9ac86eca-206f-4274-97f2-ef6c8b1f478f" target="_blank">XNA GS4 project</a>:</p><pre class="crayon-plain-tag">var interopModel = InteropModel.FromXnaModel(model);          

// and serializes it into a file
using (var fs = File.Create(&quot;model.bin&quot;))
using (var writer = new BinaryWriter(fs))
{
  interopModel.Save(writer);
}</pre><p>Then import it back into Silverlight using InteropModel.FromBinaryReader(). Here are some examples:</p>
<p><a title="3D Animated Tank" href="http://www.simonferquel.net/blog/sl3dmi/tank.html" target="_blank"><span style="color: #3e62a6;">An animated Tank</span></a></p>
<p><a title="3D Bump Mapped Lizard" href="http://www.simonferquel.net/blog/sl3dmi/lizard.html" target="_blank"><span style="color: #3e62a6;">A bump mapped Lizard</span></a></p>
<p><strong>Babylon Project</strong></p>
<p>Related, David Catuhe has added OBJ format and updated model support to the <a href="http://babylontoolkit.codeplex.com/" target="_blank">Babylon Toolkit</a>. He blogged about the toolkit updates <a href="http://blogs.msdn.com/b/eternalcoding/archive/2011/05/09/babylon-toolkit-a-toolbox-for-developing-3d-applications-with-silverlight-5.aspx" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/load-a-3d-model-in-silverlight-5-beta/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>3D Effect Class for Silverlight</title>
		<link>http://aarononeal.info/3d-effect-class-for-silverlight/</link>
		<comments>http://aarononeal.info/3d-effect-class-for-silverlight/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 20:36:20 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[hlsl]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=167</guid>
		<description><![CDATA[Summary This article explains key differences between shaders and effects and describes how to implement high-level “effect” functionality and why you might want to. If you just want the code:...]]></description>
				<content:encoded><![CDATA[<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/silverlight_detail.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="silverlight_detail" src="http://aarononeal.info/wp-content/uploads/2011/04/silverlight_detail_thumb.jpg" alt="silverlight_detail" width="90" height="67" border="0" /></a></p>
<h2>Summary</h2>
<p>This article explains key differences between shaders and effects and describes how to implement high-level “effect” functionality and why you might want to.</p>
<p>If you just want the code:</p>
<ul>
<li>Follow the procedure to setup the <a href="http://aarononeal.info/?p=145" target="_blank">HLSL Build Task with Visual Studio Integration</a></li>
<li>Download the <a href="http://code.msdn.microsoft.com/Babylon-3D-engine-f0404ace" target="_blank">Babylon Engine</a> and look at the <strong>Effect</strong> class</li>
</ul>
<h2>Named Parameters vs. Registers</h2>
<p>Silverlight provides pixel and vertex shader support in the core runtime instead of a high-level “effect” class. The shader model requires that you carefully assign constant parameters to specific registers in your HLSL so that you can set them from your application code. Consider the following HLSL.</p><pre class="crayon-plain-tag">// transform object vertices to world-space
float4x4 WorldMatrix : register(c0);

// transform object normals, tangents, &amp;amp; binormals to world-space
float4x4 WorldInverseTransposeMatrix : register(c4);

// transform object vertices to view space and project them in perspective
float4x4 WorldViewProjectionMatrix : register(c8);</pre><p>By assigning specific registers to these variables, the constants are guaranteed to be in the specified positions so that they can be set from the application side.</p><pre class="crayon-plain-tag">device.SetVertexShaderConstantFloat4(8, ref WorldViewProjectionMatrix);</pre><p>Wouldn’t it be nice if you didn’t have to manually allocate and track registers and could just refer to the parameter name “WorldViewProjectionMatrix” in your application?</p><pre class="crayon-plain-tag">effect.SetConstant(&quot;WorldViewProjectionMatrix&quot;, WorldViewProjectionMatrix);</pre><p>Your HLSL could then look like this and the compiler could allocate registers as it sees fit:</p><pre class="crayon-plain-tag">// transform object vertices to world-space
float4x4 WorldMatrix;

// transform object normals, tangents, &amp;amp; binormals to world-space
float4x4 WorldInverseTransposeMatrix;

// transform object vertices to view space and project them in perspective
float4x4 WorldViewProjectionMatrix;</pre><p>In order to make this work, you would need information about how the compiler is allocating registers to constant parameters. As it turns out this information can be obtained at compile-time from the shader compiler. However, Silverlight doesn’t ship a shader compiler with the runtime or the install size would increase considerably. A solution to this dilemma is to extract the information at compile-time into a format your application can read and then embed this as a resource alongside your compiled shader.</p>
<h2>Export the Named Parameter to Register Map</h2>
<p>For the first part of the process we need to do the following:</p>
<ol>
<li>Compile HLSL to shader byte code</li>
<li>Extract the constants table during compilation and write it to an application readable format</li>
<li>Embed the shader byte code and the constants table file as resources in an assembly</li>
</ol>
<p>Conveniently, I posted the previous article on the <a href="http://aarononeal.info/?p=145" target="_blank">HLSL Build Task with Visual Studio Integration</a> which does all of those. The constant table is exported to an XML file which looks like the following.</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ShaderConstants FileFormatVersion="1.0" Version="2.0" Constants="5"
Creator="Microsoft (R) HLSL Shader Compiler 9.29.952.3111"&gt;
  &lt;Constant Index="0" Descriptions="1"&gt;
    &lt;Description&gt;
      &lt;Name&gt;TotalSeconds&lt;/Name&gt;
      &lt;RegisterSet&gt;Float4&lt;/RegisterSet&gt;
      &lt;RegisterIndex&gt;16&lt;/RegisterIndex&gt;
      &lt;RegisterCount&gt;1&lt;/RegisterCount&gt;
      &lt;Rows&gt;1&lt;/Rows&gt;
      &lt;Columns&gt;1&lt;/Columns&gt;
      &lt;Elements&gt;1&lt;/Elements&gt;
      &lt;StructMembers&gt;0&lt;/StructMembers&gt;
      &lt;Bytes&gt;4&lt;/Bytes&gt;
      &lt;Class&gt;Scalar&lt;/Class&gt;
      &lt;Type&gt;Float&lt;/Type&gt;
    &lt;/Description&gt;
  &lt;/Constant&gt;
  …</pre><p>This XML can be easily parsed by application code to determine which registers were allocated to a specific constant, and that’s what the rest of the article is about.</p>
<h2>Effect Class</h2>
<p>We’re going to create a new class to do the following:</p>
<ul>
<li>Load a vertex and pixel shader pair from an assembly – Implementing an effect typically means configuring both a vertex and pixel shader which collaborate to produce the final result, so it makes sense to group these together under a single “effect”.
<ul>
<li>Load shader byte code</li>
<li>Load shader constants map</li>
</ul>
</li>
<li>Set shader constants by name</li>
<li>Configure the graphics device to use the loaded shaders</li>
</ul>
<p>David Catuhe did exactly this for the Effect class in his <a href="http://code.msdn.microsoft.com/Babylon-3D-engine-f0404ace" target="_blank">Babylon Engine</a>, and so I’m going to walk through what that looks like.</p>
<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/Effect1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="Effect" src="http://aarononeal.info/wp-content/uploads/2011/04/Effect_thumb1.png" alt="Effect" width="619" height="401" border="0" /></a></p>
<h3><span style="font-weight: bold;">Create the Effect and Load the Shaders</span></h3>
<p>This constructor loads the shader byte code from the named assembly and loads the constants XML file.</p><pre class="crayon-plain-tag">public Effect(GraphicsDevice device, string assemblyName,
  string vertexRootName, string pixelRootName)
{
  this.device = device;

  // Uri
  string vertexRootUri = string.Format(@&quot;/{0};component/{1}.vs&quot;,
    assemblyName, vertexRootName);
  string pixelRootUri = string.Format(@&quot;/{0};component/{1}.ps&quot;,
    assemblyName, pixelRootName);

  // Shaders
  Stream vertexShaderStream = Application.GetResourceStream(
    new Uri(vertexRootUri, UriKind.Relative)).Stream;
  Stream pixelShaderStream = Application.GetResourceStream(
    new Uri(pixelRootUri, UriKind.Relative)).Stream;

  vertexShader = VertexShader.FromStream(Device, vertexShaderStream);
  pixelShader = PixelShader.FromStream(Device, pixelShaderStream);

  vertexShaderStream.Dispose();
  pixelShaderStream.Dispose();

  // Constant tables
  ExtractConstantsRegisters(vertexRootUri + &quot;.constants&quot;, stringsToIndexesVS);
  ExtractConstantsRegisters(pixelRootUri + &quot;.constants&quot;, stringsToIndexesPS);
}</pre><p></p>
<h3><span style="font-weight: bold;">Parse Constants Table</span></h3>
<p>The constants file contains all of the information needed to determine which register a named parameter is in. This implementation stores the values in a dictionary for later reference when setting a named constant. It also allows the parameter to be referenced directly using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.effectparameter.aspx" target="_blank">EffectParameter</a> pattern to avoid dictionary lookups for greater performance.</p><pre class="crayon-plain-tag">void ExtractConstantsRegisters(string rootUri, bool isForPixelShader)
{
    using (Stream stream = Application.GetResourceStream(new Uri(rootUri, UriKind.Relative)).Stream)
    {
        XmlReader xmlReader = XmlReader.Create(stream);

        while (xmlReader.ReadToFollowing(&quot;Constant&quot;))
        {
            xmlReader.ReadToDescendant(&quot;Name&quot;);
            string name = xmlReader.ReadElementContentAsString();

            EffectParameter effectParameter;
            if (parameters.ContainsKey(name))
            {
                effectParameter = parameters[name];
            }
            else
            {
                effectParameter = new EffectParameter(device, name);
                parameters.Add(name, effectParameter);
            }

            xmlReader.ReadToNextSibling(&quot;RegisterIndex&quot;);
            int index = xmlReader.ReadElementContentAsInt();

            if (isForPixelShader)
                effectParameter.PixelShaderRegisterIndex = index;
            else
                effectParameter.VertexShaderRegisterIndex = index;

            xmlReader.ReadToNextSibling(&quot;RegisterCount&quot;);
            effectParameter.RegisterCount = xmlReader.ReadElementContentAsInt();
        }

        xmlReader.Close();
    }
}</pre><p></p>
<h3><span style="font-weight: bold;">Set Constant</span></h3>
<p>With the mapping loaded, it becomes very easy to set a constant by  name.</p><pre class="crayon-plain-tag">public void SetConstant(string propertyName, Vector4 vector4)
{
    EffectParameter effectParameter = GetParameter(propertyName);

    if (effectParameter != null)
        effectParameter.SetValue(vector4);
}</pre><p></p>
<h3><span style="font-weight: bold;">Configure Device</span></h3>
<p>Finally, we can configure the graphics device to use the pixel and vertex shader in the effect and apply the constants.</p><pre class="crayon-plain-tag">public class Effect : IDisposable
{
    // Apply
    public virtual void Apply()
    {
        // Shaders
        Device.SetVertexShader(vertexShader);
        Device.SetPixelShader(pixelShader);

        // Parameters
        foreach (EffectParameter effectParameter in parameters.Values)
        {
            effectParameter.Apply();
        }
    }
}

public class EffectParameter
{
    internal void Apply()
    {
        if (data == null)
            return;

        int size = Math.Min(RegisterCount, data.Length);

        for (int index = 0; index &amp;lt; size; index++)
        {
            if (VertexShaderRegisterIndex &amp;gt;= 0)
                device.SetVertexShaderConstantFloat4(VertexShaderRegisterIndex + index, ref data[index]);
            if (PixelShaderRegisterIndex &amp;gt;= 0)
                device.SetPixelShaderConstantFloat4(PixelShaderRegisterIndex + index, ref data[index]);
        }
    }
}</pre><p></p>
<h3><span style="font-weight: bold;">Example</span></h3>
<p>Putting it all together, you can use the effect like this.</p><pre class="crayon-plain-tag">var effect = new Effect(device, &quot;MyAssembly&quot;, &quot;Shaders/MyShader&quot;);
effect.SetConstant(&quot;World&quot;, World);
effect.SetConstant(&quot;Levels&quot;, 1.0f, 0.5f, 0, 1.3f);
effect.Apply();</pre><p>So there you go, no more messing about with manual register allocation!</p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/3d-effect-class-for-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HLSL Shader Build Task with Visual Studio Integration</title>
		<link>http://aarononeal.info/hlsl-shader-build-task-with-visual-studio-integration/</link>
		<comments>http://aarononeal.info/hlsl-shader-build-task-with-visual-studio-integration/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 18:59:59 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[hlsl]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=145</guid>
		<description><![CDATA[Do you wish Visual Studio would compile your HLSL files automatically for you? With this build task it can! This is especially useful for taking advantage of the new 3D...]]></description>
				<content:encoded><![CDATA[<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/VS.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="VS" src="http://aarononeal.info/wp-content/uploads/2011/04/VS_thumb.png" alt="VS" width="214" height="303" border="0" /></a></p>
<p>Do you wish Visual Studio would compile your HLSL files automatically for you? With this build task it can! This is especially useful for taking advantage of the new <a href="http://channel9.msdn.com/events/MIX/MIX11/MED06" target="_blank">3D Graphics support</a> in <a href="http://www.microsoft.com/silverlight/" target="_blank">Silverlight 5</a>.</p>
<p>Grab the build task on the <a href="http://code.msdn.microsoft.com/HLSL-Shader-Build-Task-285e9b53" target="_blank">MSDN Code Gallery</a>. Both the source code and the installer are included.</p>
<h2>Building</h2>
<p>To compile the solution you will need to install the <a href="http://msdn.microsoft.com/en-us/directx/aa937788">DirectX SDK</a> and the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=21307c23-f0ff-4ef2-a0a4-dca54ddb1e21">Visual Studio SDK</a>. Afterwards you can open the <strong>ShaderBuildTask</strong> solution in Visual Studio to build.</p>
<h2>Installing</h2>
<p>The easiest way to install is to build and run <strong>ShaderBuildTaskSetup</strong> which will copy the build task to the GAC. The MSI installer is included in the download if you don’t want to build it.</p>
<h2>Adding to a Project</h2>
<p>Once installed, you can update a project to support the task by adding the following to the .csproj file <strong>after the Import element for Microsoft.Silverlight.CSharp.target</strong>.</p><pre class="crayon-plain-tag">&lt;ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'"&gt;
    &lt;AvailableItemName Include="VertexShader"&gt;
      &lt;Visible&gt;false&lt;/Visible&gt;
    &lt;/AvailableItemName&gt;
    &lt;AvailableItemName Include="PixelShader"&gt;
      &lt;Visible&gt;false&lt;/Visible&gt;
    &lt;/AvailableItemName&gt;
  &lt;/ItemGroup&gt;
  &lt;UsingTask TaskName="ShaderBuildTask.ShaderCompile" AssemblyName=
"ShaderBuildTask, Version=1.0.3072.18169, Culture=neutral, PublicKeyToken=44e467d1687af125" /&gt;
  &lt;Target Name="VertexShaderCompile" Condition="'@(VertexShader)' != '' "
BeforeTargets="Build"&gt;
    &lt;ShaderCompile Sources="@(VertexShader)" ShaderProfile="vs_2_0"
IntermediateOutputPath="$(IntermediateOutputPath)"&gt;
      &lt;Output TaskParameter="Outputs" ItemName="Resource" /&gt;
    &lt;/ShaderCompile&gt;
  &lt;/Target&gt;
  &lt;Target Name="PixelShaderCompile" Condition="'@(PixelShader)' != '' "
BeforeTargets="Build"&gt;
    &lt;ShaderCompile Sources="@(PixelShader)" ShaderProfile="ps_2_0"
IntermediateOutputPath="$(IntermediateOutputPath)"&gt;
      &lt;Output TaskParameter="Outputs" ItemName="Resource" /&gt;
    &lt;/ShaderCompile&gt;
  &lt;/Target&gt;
  &lt;PropertyGroup&gt;
    &lt;PrepareResourcesDependsOn&gt;VertexShaderCompile;PixelShaderCompile;
$(PrepareResourcesDependsOn)&lt;/PrepareResourcesDependsOn&gt;
  &lt;/PropertyGroup&gt;</pre><p></p>
<h2>Visual Studio</h2>
<p>From Visual Studio, you can change the Build Action of HLSL files to either <strong>PixelShader</strong> or <strong>VertexShader</strong>. After building the project, shaders will be compiled and included in the final assembly as a resource.</p>
<p>Use <a href="http://msdn.microsoft.com/en-us/library/ms596994(v=VS.95).aspx">Application.GetResourceStream()</a> to access resources, keeping in mind that the relative path of the containing folder is preserved. For example:</p><pre class="crayon-plain-tag">var earthVertexShader = VertexShader.FromStream(
GraphicsDeviceManager.Current.GraphicsDevice,
Application.GetResourceStream(
    new Uri(@"/SolarWind;component/Shaders/Earth_vs.vs", UriKind.Relative)).Stream);</pre><p></p>
<h2>Parameters</h2>
<p>The build task supports the following parameters.</p>
<ul>
<li><strong>ShaderProfile</strong> – The profile to use (vs_2_0, ps_2_0, etc.). This is a required parameter.</li>
<li><strong>EntryPoint</strong> – The default entry point is “main” but can be overidden.</li>
<li><strong>PackMatrixRowOrder</strong> – A boolean that indicates whether to pack matrices in row major order (true) or column major (false).</li>
<li><strong>OptimizationLevel</strong> – This is only supported on new compilers (specify a value 0 to 3).</li>
<li><strong>Debug </strong>– Include debug information (default is false).</li>
<li><strong>ExportConstants </strong>– In addition to exporting a compiled shader, also export an XML file with information about the constants in the shader (default is true).</li>
<li><strong>IntermediateOutputPath </strong>– The path to export compiled shaders and constants to.</li>
</ul>
<h2>Constants Files</h2>
<p>By default, constants are exported to an XML file with the same name as the compiled shader with “.constants” appended. This data can be used to map named variables on the application side to constant registers on the shader side.</p>
<p>A sample file snippet is below.</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ShaderConstants FileFormatVersion="1.0" Version="2.0" Constants="5"
Creator="Microsoft (R) HLSL Shader Compiler 9.29.952.3111"&gt;
  &lt;Constant Index="0" Descriptions="1"&gt;
    &lt;Description&gt;
      &lt;Name&gt;TotalSeconds&lt;/Name&gt;
      &lt;RegisterSet&gt;Float4&lt;/RegisterSet&gt;
      &lt;RegisterIndex&gt;16&lt;/RegisterIndex&gt;
      &lt;RegisterCount&gt;1&lt;/RegisterCount&gt;
      &lt;Rows&gt;1&lt;/Rows&gt;
      &lt;Columns&gt;1&lt;/Columns&gt;
      &lt;Elements&gt;1&lt;/Elements&gt;
      &lt;StructMembers&gt;0&lt;/StructMembers&gt;
      &lt;Bytes&gt;4&lt;/Bytes&gt;
      &lt;Class&gt;Scalar&lt;/Class&gt;
      &lt;Type&gt;Float&lt;/Type&gt;
    &lt;/Description&gt;
  &lt;/Constant&gt;
  &lt;Constant Index="1" Descriptions="1"&gt;
    &lt;Description&gt;
      &lt;Name&gt;ViewInverseMatrix&lt;/Name&gt;
      &lt;RegisterSet&gt;Float4&lt;/RegisterSet&gt;
      &lt;RegisterIndex&gt;12&lt;/RegisterIndex&gt;
      &lt;RegisterCount&gt;4&lt;/RegisterCount&gt;
      &lt;Rows&gt;4&lt;/Rows&gt;
      &lt;Columns&gt;4&lt;/Columns&gt;
      &lt;Elements&gt;1&lt;/Elements&gt;
      &lt;StructMembers&gt;0&lt;/StructMembers&gt;
      &lt;Bytes&gt;64&lt;/Bytes&gt;
      &lt;Class&gt;Rows&lt;/Class&gt;
      &lt;Type&gt;Float&lt;/Type&gt;
    &lt;/Description&gt;
  &lt;/Constant&gt;
  …</pre><p></p>
<h2>More Information</h2>
<p>Original <a href="http://wpf.codeplex.com/releases/view/14962">WPF shader build task</a> by Greg Schechter and Gerhard Schneider. Updated by <a href="http://aarononeal.info/">Aaron Oneal</a> to include configurable properties for shader profile, entrypoint, matrix pack order, optimization level, debug, intermediate output path, and shader constants export.</p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/hlsl-shader-build-task-with-visual-studio-integration/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>HLSL Syntax Highlighting in Visual Studio 2010</title>
		<link>http://aarononeal.info/hlsl-syntax-highlighting-in-visual-studio-2010/</link>
		<comments>http://aarononeal.info/hlsl-syntax-highlighting-in-visual-studio-2010/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 19:47:37 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[hlsl]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=133</guid>
		<description><![CDATA[I was looking for a quick way to get syntax highlighting for HLSL inside VS 2010 and came across the NShader project. Install the extension, restart VS, and if you’re...]]></description>
				<content:encoded><![CDATA[<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/image3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://aarononeal.info/wp-content/uploads/2011/04/image_thumb3.png" width="464" height="199" /></a></p>
<p>I was looking for a quick way to get syntax highlighting for HLSL inside VS 2010 and came across the <a href="http://nshader.codeplex.com/" target="_blank">NShader project</a>. Install the extension, restart VS, and if you’re using the default VS color scheme you’re good to go.</p>
<p>I picked up a nice color scheme over at <a href="http://studiostyl.es/" target="_blank">StudioStyles</a> and wanted the HLSL highlighting to match. This required deleting the following key using the registry editor:</p>
<blockquote><p><font face="Consolas">HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\FontAndColors\Cache</font></p>
</blockquote>
<p>Then it was off to <em>Tools/Options/Environment/Fonts and Colors </em>to update the “Shader Language” color entries to match.</p>
<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/image4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://aarononeal.info/wp-content/uploads/2011/04/image_thumb4.png" width="541" height="313" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/hlsl-syntax-highlighting-in-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 3D Samples from MIX11</title>
		<link>http://aarononeal.info/silverlight-3d-samples-from-mix11/</link>
		<comments>http://aarononeal.info/silverlight-3d-samples-from-mix11/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 01:50:57 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mix]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=125</guid>
		<description><![CDATA[The 3D samples from my MIX11 session are now online. You can grab them on MSDN Code Gallery. XNA Math Library – Math library from XNA which is planned for...]]></description>
				<content:encoded><![CDATA[<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/image.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://aarononeal.info/wp-content/uploads/2011/04/image_thumb.png" width="244" height="160" /></a></p>
<p>The 3D samples from my <a href="http://channel9.msdn.com/events/MIX/MIX11/MED06" target="_blank">MIX11 session</a> are now online. You can grab them on <a href="http://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=Technology&amp;f%5B0%5D.Value=Silverlight&amp;f%5B1%5D.Type=Topic&amp;f%5B1%5D.Value=Graphics%20and%203D" target="_blank">MSDN Code Gallery</a>.</p>
<p><a href="http://code.msdn.microsoft.com/XNA-Math-Helper-DLL-d4d1f7d4" target="_blank">XNA Math Library</a> – Math library from XNA which is planned for the SDK.</p>
<p><a href="http://code.msdn.microsoft.com/Triangle-Sample-3D-a69d04b4" target="_blank">Triangle Sample</a> – Draw a simple triangle by specifying vertices with position and color.</p>
<p><a href="http://code.msdn.microsoft.com/Colored-Non-Textured-3D-c0e3cda6" target="_blank">Color Cube Sample</a> – Draw a rotating cube with solid or gradient color faces.</p>
<p><a href="http://code.msdn.microsoft.com/Animated-Textured-Cube-72c66eea" target="_blank">Animated Textured Cube Sample</a> – Draw a rotating cube with texture shaded faces.</p>
<p><a href="http://code.msdn.microsoft.com/Controllable-Textured-3D-f7b1beab" target="_blank">Controllable Textured Cube Sample</a> – Draw a textured cube that can be rotated by Silverlight UI controls.</p>
<p><a href="http://code.msdn.microsoft.com/Solar-Wind-3D-Sample-4cb56170" target="_blank">Solar Wind Sample</a> – Draw the Earth with day and night transitions, atmosphere layers, and population density overlays. Demonstrates more advanced concepts like mipmaps, texture blending, multiple drawing passes, sampler states, and lighting.</p>
<p><a href="http://code.msdn.microsoft.com/Babylon-3D-engine-f0404ace" target="_blank">Windows Café with the Babylon Engine</a> – Make a virtual visit to the Windows Café in Paris. David Catuhe blogged about it <a href="http://blogs.msdn.com/b/eternalcoding/archive/2011/04/21/babylon-engine-on-code-msdn-microsoft-com.aspx" target="_blank">here</a>.</p>
<p><a href="http://code.msdn.microsoft.com/3D-Housebuilder-demo-from-def4af04" target="_blank">House Builder</a> – John Papa wrote about this demo he showed in the keynote <a href="http://johnpapa.net/3dmix11" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/silverlight-3d-samples-from-mix11/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Silverlight 3D Graphics at MIX11</title>
		<link>http://aarononeal.info/silverlight-3d-graphics-at-mix11/</link>
		<comments>http://aarononeal.info/silverlight-3d-graphics-at-mix11/#comments</comments>
		<pubDate>Sat, 09 Apr 2011 17:55:55 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mix]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=119</guid>
		<description><![CDATA[I’ll be at MIX11 on Wednesday April 13th to talk about a fantastic new feature coming to Silverlight 5 – 3D Graphics! I hope you can make the session or...]]></description>
				<content:encoded><![CDATA[<p><a href="http://aarononeal.info/wp-content/uploads/2011/04/MIX11_BB_ImSpeakingAt_1.gif"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="MIX11_BB_I&#39;mSpeakingAt_1" border="0" alt="MIX11_BB_I&#39;mSpeakingAt_1" src="http://aarononeal.info/wp-content/uploads/2011/04/MIX11_BB_ImSpeakingAt_1_thumb.gif" width="156" height="244" /></a></p>
<p>I’ll be at MIX11 on Wednesday April 13th to talk about a fantastic new feature coming to Silverlight 5 – 3D Graphics! I hope you can make <a href="http://live.visitmix.com/MIX11/Sessions/Speaker/Aaron-Oneal">the session</a> or check it out <a href="http://channel9.msdn.com/events/MIX/MIX11/MED06">online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/silverlight-3d-graphics-at-mix11/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Change the Computer Name on a Mac</title>
		<link>http://aarononeal.info/change-the-computer-name-on-a-mac/</link>
		<comments>http://aarononeal.info/change-the-computer-name-on-a-mac/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 22:00:11 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[computer name]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=115</guid>
		<description><![CDATA[Normally you can change the computer name on a Mac by going to System Preferences / Sharing. After binding a workstation to Open Directory I was unable to change this...]]></description>
				<content:encoded><![CDATA[<p>Normally you can change the computer name on a Mac by going to System Preferences / Sharing.</p>
<p><a href="http://aarononeal.info/wp-content/uploads/2011/02/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://aarononeal.info/wp-content/uploads/2011/02/image_thumb.png" alt="image" width="372" height="306" border="0" /></a></p>
<p>After binding a workstation to Open Directory I was unable to change this setting using that dialog. Instead, you can change the name using the Terminal.</p>
<p><code><span style="font-family: 'Courier New';">scutil --set ComputerName NewName</span></code></p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/change-the-computer-name-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Age of Mythology Under Parallels</title>
		<link>http://aarononeal.info/age-of-mythology-under-parallels/</link>
		<comments>http://aarononeal.info/age-of-mythology-under-parallels/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 20:14:47 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[age of mythology]]></category>
		<category><![CDATA[graphics card]]></category>
		<category><![CDATA[parallels]]></category>
		<category><![CDATA[video adapter]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=105</guid>
		<description><![CDATA[Age of Mythology: Including Titans Expansion is a great game, and since the Titan’s Expansion was never released for the Mac, running the PC version is a job for Parallels....]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/B000P5BSUQ?ie=UTF8&amp;tag=aaronesblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B000P5BSUQ"><img style="text-align: center; background: #f3f3f3; border: #ddd 1px solid; padding: 4px;" title="AoM" src="http://aarononeal.info/wp-content/uploads/2011/02/AoM_thumb.png" alt="AoM" width="184" height="115" border="0" /></a><img style="margin: 0px; border-style: none !important;" src="http://www.assoc-amazon.com/e/ir?t=aaronesblo-20&amp;l=as2&amp;o=1&amp;a=B000P5BSUQ" alt="" width="1" height="1" border="0" /></p>
<p><a href="http://www.amazon.com/gp/product/B000P5BSUQ?ie=UTF8&amp;tag=aaronesblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B000P5BSUQ">Age of Mythology: Including Titans Expansion</a><img style="margin: 0px; border-style: none !important;" src="http://www.assoc-amazon.com/e/ir?t=aaronesblo-20&amp;l=as2&amp;o=1&amp;a=B000P5BSUQ" alt="" width="1" height="1" border="0" /> is a great game, and since the Titan’s Expansion was never released for the Mac, running the PC version is a job for Parallels. Unfortunately, Age of Mythology doesn’t like the video driver Parallels uses.</p>
<p><span style="font-family: 'Courier New';">This graphics card is not supported by Age of Mythology. Please check microsoft.com for a list of supported graphics cards. Age of Mythology will now exit.</span></p>
<p><span style="font-family: 'Courier New';">Video Card 0: prl_vadd.dll Parallels Video Adapter Vendor(0x1AB8) Device(0&#215;4005)</span></p>
<p>Fortunately, you can fix this by dropping some new driver definitions into the following folder:</p>
<p><span style="font-family: 'Courier New';">C:\Program Files\Microsoft Games\Age of Mythology\gfxconfig2</span></p>
<p>The definitions are attached below and just need to be unzipped to that folder.</p>
<p><a href="http://aarononeal.info/wp-content/uploads/2011/02/ParallelsAoM.zip">AoM Driver Definitions for Parallels</a></p>
<p>You may also want to modify your startup shortcut to skip intro cinematics and begin in widescreen.</p>
<p><span style="font-family: 'Courier New';">&#8220;C:\Program Files\Microsoft Games\Age of Mythology\aomx.exe&#8221; +noIntroCinematics xres=1680 yres=1050 bpp=32</span></p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/age-of-mythology-under-parallels/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mac With Insomnia</title>
		<link>http://aarononeal.info/mac-with-insomnia/</link>
		<comments>http://aarononeal.info/mac-with-insomnia/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 20:40:15 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mesh]]></category>
		<category><![CDATA[sleep]]></category>

		<guid isPermaLink="false">http://aarononeal.info/?p=78</guid>
		<description><![CDATA[One thing I have struggled with through the years is getting computers to sleep and wake up like they’re supposed to. I have usually found the culprit to be one...]]></description>
				<content:encoded><![CDATA[<p><img style="border: 1px solid #DDD; text-align: center; background: #F3F3F3; padding: 4px;" src="http://aarononeal.info/wp-content/uploads/2011/02/CatGuitarSleep.png" /></p>
<p>One thing I have struggled with through the years is getting computers to sleep and wake up like they’re supposed to. I have usually found the culprit to be one of the following:</p>
<ul>
<li>Outdated BIOS </li>
<li>Hardware or expansion cards that never supported it in the first place </li>
<li>USB device or HUB that wasn’t energy friendly </li>
<li>Poorly tested device drivers </li>
<li>Overactive or misbehaving software </li>
</ul>
<p>After making sure I have the latest updates to everything, the general troubleshooting technique I follow is to strip the computer or OS down to the bare minimum. Remove all expansion cards and external devices, shutdown all applications, go over running processes with a fine toothed comb, log out, and then verify that the computer sleeps in this clean state.</p>
<p>If that still doesn’t work, to verify it’s not a software issue, sometimes I’ll boot a clean OS from alternate media.</p>
<p>After working perfectly fine for weeks, my new Mac was hit with a bout of insomnia. I could put the computer to sleep manually but it refused to honor the computer sleep timer in Energy Saver preferences. Those long, sleepless nights apparently drained my wireless keyboard and trackpad batteries in short order.</p>
<p>To troubleshoot, I dropped the sleep timer down to 1 minute and waited. The display would blank, but after 10 minutes the computer remained on. Now, under normal conditions, it still takes longer than 1 minute to sleep (more like 3 or so), but eventually it would.</p>
<p>I logged out and sure enough, after a couple minutes the computer slept. So, it had something to do with a running application. I quit all my apps, including those running in the background like Dropbox, Live Mesh, etc. After a few minutes, the computer went to sleep. Through process of elimination I determined that the culprit was Windows Live Mesh. I filed a bug with Microsoft, so hopefully we can troubleshoot this to determine the root cause.</p>
<p>If you’re experiencing a similar issue and are unable to identify it using these steps, you might want to check out a nice little utility called <a href="http://www.dragonone.com/products/macosx/pleasesleep/" target="_blank">PleaseSleep</a>. It didn’t work in my case, but I have heard overall it has good success forcing the computer to sleep when it is supposed to. The app also records some nice logging information to aid in troubleshooting.</p>
<p><a href="http://www.dragonone.com/products/macosx/pleasesleep/"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PleaseSleepPreview" border="0" alt="PleaseSleepPreview" src="http://aarononeal.info/wp-content/uploads/2011/02/PleaseSleepPreview.jpg" width="240" height="201" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://aarononeal.info/mac-with-insomnia/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Object Caching 1376/1397 objects using apc

 Served from: aarononeal.info @ 2013-06-18 23:51:28 by W3 Total Cache -->