Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a custom shader and try to pass the effect on my Models like that:

foreach (ModelMesh mesh in Model.Meshes)
       foreach (ModelMeshPart part in mesh.MeshParts)
           part.Effect = effect;

My only issue is that every Model now has its own light source in it. Why is this happening and is this a problem of my shader?


These are the parameters passed to the shader:

      private void Get_lambertEffect()
                if (_lambertEffect == null) _lambertEffect = Engine.LambertEffect;

                //Lambert technique (LambertWithShadows, LambertWithShadows2x2PCF, LambertWithShadows3x3PCF)
                _lambertEffect.CurrentTechnique = _lambertEffect.Techniques["LambertWithShadows3x3PCF"];

                //ShadowMap parameters

                //Camera view and projection parameters
                Matrix.CreateScale(Size) *
                //Light and color
                _lambertEffect.Parameters["colorMap"].SetValue(ColorTexture.Create(Engine.GraphicsDevice, Color.Red));



enter image description here

share|improve this question
By "own light source" do you mean, that each model is illuminated by a different light source and you only want one light source in the scene? Need to see your shader... – Ken Oct 18 '12 at 10:31
That's exactly what I mean. The shader was working fine when I was working with primitives but now that I switched to Models I am having this issue. I'll take a look at it. – alecnash Oct 18 '12 at 10:36
maybe we could have a look at the parameters passed to the shader – Ken Oct 18 '12 at 10:54
Just uploaded them – alecnash Oct 18 '12 at 11:00
Can you post a screenshot of what this looks like? I can't figure out what you mean by "each model has its own light source" – melak47 Oct 18 '12 at 13:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.