This project is read-only.

Using Custom Shader

Apr 9, 2010 at 9:58 PM

Hi I'm currently using XNAnimation with great success, I am currently attempting to use my own shader for some toon effects.

I Have no issues with getting the skinning working, my problems occur with my Model's textures. It appears that the texture is being dominated by a single texture.

I tried removing the toon stuff from my custom shader so that it was just an identical copy of the original and it still renders incorrectly, but when i switch back to the SkinnedModelBasicEffect everything's fine.


I switch in the new shader using some code from another discussion:


foreach (ModelMesh mesh in this.Model.Meshes)
      for (int i = 0; i < mesh.MeshParts.Count; i++)
            // get the texture that the xnanimation content pipeline loaded for this mesh part
	    Texture2D diffuse = mesh.MeshParts[i].Effect.Parameters["diffuseMap0"].GetValueTexture2D();
	    bool	diffuseEnabled = mesh.MeshParts[i].Effect.Parameters["diffuseMapEnabled"].GetValueBoolean();
            // set our new effect - which clears the texture and values set by the pipeline
            mesh.MeshParts[i].Effect = this.m_Effect;
            // set the texture of our new effect

Has anyone encountered this problem before and found any solutions?