Content processor parameters in XNA Game Studio 2.0

One of the 2.0 features I am personally happiest about is the addition of custom parameters to control how your content gets built. This is something we always wanted to do, but didn't have time for in v1, so it feels great to be able to finally finish our original design!

The most obvious impact of this change is that the previous muddle of TextureProcessor, SpriteTextureProcessor, and ModelTextureProcessor class has been replaced with a single improved TextureProcessor. Here it is in the Visual Studio properties window:

See that little + box to the left of the "Content Processor" label? Guess what happens if you expand it:

Tada! If you don't like our default texture format or color keying behavior, you can now easily change this without having to write any custom processor code.

Even better, remember the hoops you had to jump through to customize how models built their textures? Not any more. The built in ModelProcessor now provides parameters controlling not only the 3D model processing, but also how to build any textures that are used on the model:

It is easy to add custom parameters to your own processors. Simply create a public property:

    public class MyProcessor : ContentProcessor<MyType, MyOtherType>
        public float numberOfCats;
            get { return numberOfCats; }
            set { numberOfCats = value; }

        float numberOfCats = 23;


This will automatically show up in Visual Studio when your processor is selected. For bonus points you can include attributes to customize how the property is displayed and initialized:

   [DisplayName("Number of cats")]
   [Description("Sets how many cats you wish to splice afore the mizzen")]
   public float numberOfCats;

I'm excited about the possibilities this will open up for more powerful and reusable content processors. Imagine if the VegetationProcessor from the Billboard Sample let you choose what textures to use, or if the NormalMapProcessor from the Sprite Effects Sample let you choose how bumpy a normalmap to create...

Comments (9)

  1. Ultrahead says:

    From the pictures above, by setting "Generate tangent frames" to "true", the processor then (re)generates the normal, tangent and binormal vectors for the model, or is it something different?

  2. snprbob86 says:

    I’m not sure how the PropertyGrid control would handle this, but if it’s "gracefully", why not merge Color Key Color and Color Key Enabled to just be a nullable Color Key?

  3. barret232hxc says:

    sorry to sound newbish but I was just wondering how you create a public property. I see the option to add a new content processor. Any direction in this subject would be greatly appreciated.

    On another note that’s awesome that we can change these attributes so easy 🙂

  4. mrandall says:

    Just a heads up for anyone new to C# trying to use this information. You need to also include the following line to your list of assemblies if you wish to support the [DefaultValue()], [DisplayName()] and [Description()] method attributes.

    using System.ComponentModel;

  5. wolfenstein99 says:

    Hi Shawn,

    I have the following code in a Custom Texture Processor class:

    private Color colorKeyColor = Color.White;

    [DisplayName("Color Key Color")]


    [Description("Color Key")]

    public Color ColorKeyColor


       get { return colorKeyColor; }

       set { colorKeyColor = value; }


    The problem is that the ColorKeyColor prop only shows up as a textbox in the Property Grid, how to I get it to have nested R,G,B,A properties like the standard Texture Processor?

    Also If I uncomment the "[DefaultValue(Color.Magenta)]" line I get an error. How can I set the default Color for this property in the PropertyGrid?


    – Chris W

  6. wolfenstein99 says:

    OK, it looks like you have to type the Color into the text box in the format: R,B,G,A

    Then after you compile the nested R,B,G,A props become available.

    I take it the "[DefaultValue(Color.Magenta)]" entry won’t work though?

  7. wolfenstein99 says:

    Looks like I answered my own question again.

    You need to do: [DefaultValue(typeof(Color), "0, 255, 0, 255")]

  8. mike says:

    In xna 3.1, is it possible to set the processor parameters in code. The context is if i was use msBuild to build content, it seems like i’m stuck using the default  values for the model processor.

  9. ShawnHargreaves says:

    mike: I would recommend the forums on for this question. Blog post comments aren’t really the best place for posting code snippets etc!

Skip to main content