This article is prerecorded. Shawn is away (on honeymoon). Replies to comments will be delayed.
In previous XNA versions, the Content Pipeline imported materials like so:
- If an FBX or X model directly references a .fx effect, the importer creates an EffectMaterialContent, which becomes a custom Effect when loaded into your game.
- Otherwise the importer creates a BasicMaterialContent, which is loaded as a BasicEffect.
- BasicMaterialContent properties such as texture, diffuse color, and specular power are set from the source FBX or X material.
- If the source has other material properties that BasicEffect does not support, these are stored in BasicMaterialContent.OpaqueData, in case a custom processor wants to do something cool with them.
To use custom effects that are not directly referenced by a model, you have two options:
- Use a custom processor to apply the effect (see this sample).
- Or you can do it at runtime (see the ChangeEffectUsedByModel method from this sample).
Game Studio 4.0 works the same way, but adds a new processor parameter for choosing which of the five built-in effects is selected by default (if the source model does not directly reference a .fx material):
Along with this parameter come new design-time material types, so BasicMaterialContent is joined by SkinnedMaterialContent, EnvironmentMapMaterialContent, etc.
Depending which effect you choose, some additional work may be needed to configure it:
- If you use SkinnedEffect, you must call SetBoneTransforms to set the current animation state.
- If you use EnvironmentMapEffect, you must provide a suitable cubemap. You can do this either at runtime or in a custom content processor, but just setting the Default Effect processor parameter to EnvironmentMapEffect will not do this for you, because it has no way to know which cubemap you want to use.
- If you use DualTextureEffect, the second texture can be automatically imported from FBX materials. If the FBX does not specify a second texture, you must set it yourself, either at runtime or in a custom content processor (see the DualTextureProcessor from this example).