   Assistance applying a different shader (material) for each mesh
  Hello: Can you please assist me in talking through the theory on this? Currently, my load routine (for a single, given model) looks like this:(1) Load an effect file based on the model name(2) Loop through the meshes, modelparts, and effects to get the annotations for the textures to be loaded(3) Load textures based on step 2My draw routine looks like this:(1) Loop through the meshes and meshparts and apply an effect(2) Set the effect parameters, including textures(3) DrawCode for load1 baseModel = Game.Content.Load<Model>(modelName); 2 3 switch (modelName) 4 { 5 case "Cube_ShaderFX_JPG": 6 effect = Game.Content.Load<Effect>("Cube_ShaderFX"); 7 break; 8 case "Punk": 9 effect = Game.Content.Load<Effect>("Punk_FX"); 10 break; 11 case "Factory": 12 effect = Game.Content.Load<Effect>("Factory_2"); 13 break; 14 } 15 16 17 // Load Textures // 18 19 foreach (ModelMesh mesh in baseModel.Meshes) 20 { 21 foreach (Effect mesheffect in mesh.Effects) 22 { 23 foreach (EffectParameter param in effect.Parameters) 24 { 25 if (param.Name.ToString() == "DIF") 26 { 27 diffuseTexture = Game.Content.Load<Texture>(Path.GetFileNameWithoutExtension(param.Annotations["Name"].GetValueString())); 28 } 29 if (param.Name.ToString() == "SPEC") 30 { 31 specularTexture = Game.Content.Load<Texture>(Path.GetFileNameWithoutExtension(param.Annotations["Name"].GetValueString())); 32 } 33 if (param.Name.ToString() == "NOR") 34 { 35 normalTexture = Game.Content.Load<Texture>(Path.GetFileNameWithoutExtension(param.Annotations["Name"].GetValueString())); 36 } 37 } 38 } 39 } Partial code for draw1 foreach (ModelMesh mesh in baseModel.Meshes) 2 { 3 foreach (ModelMeshPart p in mesh.MeshParts) 4 { 5 p.Effect = effect; 6 7 p.Effect.Parameters["DIF"].SetValue(diffuseTexture); 8 p.Effect.Parameters["SPEC"].SetValue(specularTexture); 9 p.Effect.Parameters["NOR"].SetValue(normalTexture); 10 11 p.Effect.Parameters["world"].SetValue(worldMatrixTrans * mesh.ParentBone.Transform); 12 p.Effect.Parameters["wvp"].SetValue(worldMatrixTrans * mesh.ParentBone.Transform * BaseCamera.viewMatrix * BaseCamera.projectionMatrix); 13 14 Matrix worldInverseMatrix = Matrix.Invert(mesh.ParentBone.Transform * worldMatrixTrans); 15 p.Effect.Parameters["worldI"].SetValue(worldInverseMatrix); 16 17 Matrix worldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(mesh.ParentBone.Transform * worldMatrixTrans)); 18 p.Effect.Parameters["worldIT"].SetValue(worldInverseTransposeMatrix); 19 20 Matrix viewInverseTransposeMatrix = Matrix.Invert(BaseCamera.viewMatrix); 21 p.Effect.Parameters["viewInv"].SetValue(viewInverseTransposeMatrix); So now I want to introduce multiple meshes each with their own material (fx file) per model.Question: I would ASSUME that mesh.Effects would be the effect (fx) file specified in my .x file. My debugging doesn't necessarily seem to reflect this. So should my Game.Content.Load<Effect>... come in the ModelMesh mesh loop? I would think that I could get the effect name (somehow) from mesh.Effects and then do a content.load and then get my textures. I can't seem to make that part work, though.Any advice or example code would be wonderful. Thanks!
  should be "mesheffect" not "effect". modified the case statement (changed where the load happens and updated to use collections) and it works like a champ!   