Search code examples
xnamonogame

Monogame Custom Effect


Me and my friends wanted to implement a custom effect which is hooked up to a mesh during the "build content" process in Monogame pipeline. That is, if a model consists, say, of 10 different meshes each one with their own effect, it would make our life much easier.

As far as I am concerned, doing this used to be trivial, something like that: https://blogs.msdn.microsoft.com/shawnhar/2006/12/07/rendering-a-model-with-a-custom-effect/

Now that way of doing thigs does not work at for us, unfortunately. We wrote a custom model processor, custom model material processor and a custom texture processor.

EffectMaterialContent myMaterial = new EffectMaterialContent();

myMaterial.Effect = new ExternalReference<EffectContent>(effectPath);

And so we get the following exception:

{"Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Microsoft.Xna.Framework.Content.Pipeline.Graphics.EffectMaterialContent, MonoGame.Framework.Content.Pipeline, Version=3.6.0.199, Culture=neutral, PublicKeyToken=null]] (Microsoft.Xna.Framework.Content.ReflectiveReader`1[[Microsoft.Xna.Framework.Content.Pipeline.Graphics.EffectMaterialContent, MonoGam e.Framework.Content.Pipeline]])"}

Seems like there is a simple way of doing this, but it eludes us. We would greatly appreciate your help!


Solution

  • I believe we managed to solve the problem more or less. Here is a question I posted on the Monogame community forum. It's not complete by all means, but I believe it provides a good general understanding of the underlying problem.

    http://community.monogame.net/t/mesh-effect-field/7462