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

  • \$\begingroup\$ 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... \$\endgroup\$ – Ken Oct 18 '12 at 10:31
  • \$\begingroup\$ 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. \$\endgroup\$ – alecnash Oct 18 '12 at 10:36
  • \$\begingroup\$ maybe we could have a look at the parameters passed to the shader \$\endgroup\$ – Ken Oct 18 '12 at 10:54
  • \$\begingroup\$ Just uploaded them \$\endgroup\$ – alecnash Oct 18 '12 at 11:00
  • \$\begingroup\$ 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" \$\endgroup\$ – user13213 Oct 18 '12 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.