assigning values to shader parameters in the XNA content pipeline
Posted
by
Nick
on Game Development
See other posts from Game Development
or by Nick
Published on 2012-10-26T09:32:01Z
Indexed on
2012/10/26
11:18 UTC
Read the original article
Hit count: 481
I have tried creating a simple content processor that assigns the custom effect I created to models instead of the default BasicEffect.
[ContentProcessor(DisplayName = "Shadow Mapping Model")]
public class ShadowMappingModelProcessor : ModelProcessor
{
protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
{
EffectMaterialContent shadowMappingMaterial = new EffectMaterialContent();
shadowMappingMaterial.Effect = new ExternalReference<EffectContent>("Effects/MultipassShadowMapping.fx");
return context.Convert<MaterialContent, MaterialContent>(shadowMappingMaterial, typeof(MaterialProcessor).Name);
}
}
This works, but when I go to draw a model in a game, the effect has no material properties assigned. How would I go about assigning, say, my DiffuseColor or SpecularColor shader parameter to white or (better) can I assign it to some value specified by the artist in the model? (I think this may have something to do with the OpaqueDataDictionary but I am confused on how to use it--the content pipeline has always been a black box to me.)
© Game Development or respective owner