Jump to content
  • Advertisement
Sign in to follow this  

Access texture of model

This topic is 2080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys


Ive been working with the toon shader sample from the microsoft xbox live website(link below) and wanted to apply the

effect to the skinning sample also from the website and wanted to know if there was a way to extract texture info

from a model without using the basiceffect










toon shader link



animated model link







portion of code wanting to modify from this:

 foreach (BasicEffect oldEffect in mesh.Effects)

To this and still be able to access the texture of the animated model

 foreach (Effect oldEffect in mesh.Effects)

complete code

  static void ChangeEffectUsedByModel(Model model, Effect replacementEffect)
            // Table mapping the original effects to our replacement versions.
            Dictionary<Effect, Effect> effectMapping = new Dictionary<Effect, Effect>();

            foreach (ModelMesh mesh in model.Meshes)
                // Scan over all the effects currently on the mesh.
                foreach (BasicEffect oldEffect in mesh.Effects)
                    // If we haven't already seen this effect...
                    if (!effectMapping.ContainsKey(oldEffect))
                        // Make a clone of our replacement effect. We can't just use
                        // it directly, because the same effect might need to be
                        // applied several times to different parts of the model using
                        // a different texture each time, so we need a fresh copy each
                        // time we want to set a different texture into it.
                        Effect newEffect = replacementEffect.Clone(

                        // Copy across the texture from the original effect.


                        effectMapping.Add(oldEffect, newEffect);

                // Now that we've found all the effects in use on this mesh,
                // update it to use our new replacement versions.
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                    meshPart.Effect = effectMapping[meshPart.Effect];

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!