<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx</link><description>If you want to use your own effect for model rendering, you have basically two choices. You could just let the content pipeline do its stuff and then replace the output data with your own effect at runtime, or you could use a custom processor to specify</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#1239403</link><pubDate>Fri, 08 Dec 2006 16:38:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1239403</guid><dc:creator>jack_</dc:creator><description>&lt;p&gt;Hi Shawn,&lt;/p&gt;
&lt;p&gt;Thank you for this sample. This is almost what I have searched for.&lt;/p&gt;
&lt;p&gt;But, just create an constant “MyEffect.fx” Effect, well it’s ok for a sample. It would be better to use a dependency to the input material. If I use some kind of factory class, e.g. MaterialLibManager to create the Effect, it would be nice to do something like this :&lt;/p&gt;
&lt;p&gt;protected override ModelContent ConvertMaterial(ModelContent material, ContentProcessorContext context)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	EffectMaterialContent myMaterial = MaterialLibManager.Convert(material.Name);&lt;/p&gt;
&lt;p&gt;	If (myMaterial == null)&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		return base.ConvertMaterial(material, context);&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;
&lt;p&gt;	return base.ConvertMaterial(myMaterial, context);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;So this leads again to the ‘not imported material name problem’. The MaterialLibManager class could contain a list of valid names (maybe loaded via xml file) and appropriate preset parameter.&lt;/p&gt;
&lt;p&gt;To use just the fx - file name is not sufficient, because there could be different materials that use the same fx-file (e.g. Wood and Rubber uses &amp;nbsp;phongbump.fx) with just some other parameter values.&lt;/p&gt;
&lt;p&gt;So, some kind of “keydata” that comes from the model tool to the XNA Framework.&lt;/p&gt;
&lt;p&gt;PS: &lt;/p&gt;
&lt;p&gt;I guess the first override method in your example should be the Process method (as you mention) not the ConvertMaterial ;-)&lt;/p&gt;
</description></item><item><title>re: Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#1241781</link><pubDate>Fri, 08 Dec 2006 22:39:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1241781</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;You actually don't normally need to override Process to alter the materials: just ConvertMaterial is enough.&lt;/p&gt;
&lt;p&gt;Regarding getting more information about each material, our importers do their best to pull through as much data as we can find, but in this regard we're pretty much at the mercy of the file formats that we are reading from.&lt;/p&gt;
&lt;p&gt;The X format unfortunately doesn't include name strings for materials, so all we get there is the effect settings.&lt;/p&gt;
&lt;p&gt;FBX has a significantly richer system for exporting metadata, so if you import from FBX, we will be able to populate the Name property correctly for materials.&lt;/p&gt;
</description></item><item><title>re: Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#1322640</link><pubDate>Tue, 19 Dec 2006 08:08:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1322640</guid><dc:creator>Pon</dc:creator><description>&lt;p&gt;Hi Shawn. As said above, this is great if you want to hardcode the effect, but it doesn't address having different effects.&lt;/p&gt;
&lt;p&gt;In 3ds MAX, for example, you can explicitly set effect parameters, as well as the effect and the textures. How would one go about extracting that data, and setting the appropriate Parameters[], as well as loading in the textures needed by the effects, in a content processor and/or importer? By the way, I'm using FBX for my models.&lt;/p&gt;
&lt;p&gt;~~Pon&lt;/p&gt;
</description></item><item><title>re: Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#1351634</link><pubDate>Sat, 23 Dec 2006 14:35:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1351634</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;FBX doesn't (currently, this will hopefully change in the near future) support the Max effects implementation, but hopefully Autodesk will add that soon. It has good metadata for pulling through material names, which you could use to re-populate the effect data in your processor, but you won't be able to fully automate this from the Max material since that data isn't in the FBX file.&lt;/p&gt;
&lt;p&gt;If you are setting up your effects directly in Max, .X might be a better format since that does currently support materials based on D3D Effects (but then it doesn't include the material name data: swings and roundabouts really, neither format is quite perfect yet...)&lt;/p&gt;
</description></item><item><title>re: Rendering a Model with a custom Effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#1443552</link><pubDate>Wed, 10 Jan 2007 14:39:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1443552</guid><dc:creator>jack_</dc:creator><description>&lt;p&gt;Hi Shawn,&lt;/p&gt;
&lt;p&gt;&amp;gt;but then it doesn't include the material name data (inside the X File)&lt;/p&gt;
&lt;p&gt;I'm sorry but this is not right.&lt;/p&gt;
&lt;p&gt;You get the material names exported with the Panda and kw exporter. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;example :&lt;/p&gt;
&lt;p&gt;Material BasicRed { &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt; 0.780392;0.200000;0.121569;1.000000;;&lt;/p&gt;
&lt;p&gt; 3.200000;&lt;/p&gt;
&lt;p&gt; 0.000000;0.000000;0.000000;;&lt;/p&gt;
&lt;p&gt; 0.000000;0.000000;0.000000;;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Actually every x-file template can have a name and it is not difficult to get it via MDX XFileData object. Well, mixing XNA with MDX... I don't think that's a good way, but there ist no XFile class in XNA. And for the content processing you can add the Direct3DX assembly, but is this compatible with a Xbox360 build?&lt;/p&gt;
&lt;p&gt;Another file format that support fx Shader parameter and names is the collada format.&lt;/p&gt;
&lt;p&gt;Native collada support in XNA would be great,&lt;/p&gt;
&lt;p&gt;but I think there are allready some user importer around.&lt;/p&gt;
</description></item><item><title>rendering-a-model-with-a-custom-effect</title><link>http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx#6830865</link><pubDate>Sat, 22 Dec 2007 02:11:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6830865</guid><dc:creator>ひにけにXNA</dc:creator><description>&lt;p&gt;フォーラムの質問を見て、今まで書いていなかったことに気づいたので遅ればせながらカスタムエフェクトの使い方を説明します。 例によって例の如く、コピー元は Shawn Hargreaves氏の投稿 からです。&lt;/p&gt;
</description></item></channel></rss>