Original Post
Hi, I recently noticed an issue with my renderer. I am using the XSI run-time to render skinned meshes in my XNA game. When I apply a rotation to my model via the the world transformation the lighting seems to get applied before the model is rotated by the world transforms. Meaning, I place a cube in the world with a light directly in front of it. The front of the cube is fully lit, and the back is in complete darkness. I then rotate the cube with the world transform. I have not moved the light. However, the front is now in complete darkness with the back now fully lit. It should not have changed. I'm not even sure it is apply to bone transformations either, but I haven't been able to get a simple test up and running yet. I am using the basic Phong.fx shader that comes with XSI|Mod Tool. Has anyone experienced this before and found a solution? Here is most of my rendering code. [Edited by - matthughson on February 19, 2010 6:34:16 PM]
foreach (ModelMesh mesh in mModel.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
if (effect.GetType() == typeof(BasicEffect))
{
throw new ArgumentException("A model inside " + mFileName + " does not have a shader assigned to it.");
}
else
{
bool isSkinned = (bones.GetLength(0) > 0);
// set the technique
if (isSkinned && (effect.Techniques["Skinned"] != null))
{
effect.CurrentTechnique = effect.Techniques["Skinned"];
}
else
{
if (effect.Techniques["Static"] != null)
{
effect.CurrentTechnique = effect.Techniques["Static"];
}
else
{
effect.CurrentTechnique = effect.Techniques[0];
}
}
// bind bones
if ((effect.Parameters["Bones"] != null) && isSkinned)
effect.Parameters["Bones"].SetValue(bones);
//Set paramaters
effect.Parameters["Model"].SetValue(transforms[mesh.ParentBone.Index] * world);
effect.Parameters["View"].SetValue(CameraManager.pInstance.pCameraViewMatrix);
effect.Parameters["Projection"].SetValue(CameraManager.pInstance.pCameraProjectionMatrix);
effect.Parameters["lightpos0"].SetValue(LightingManager.pInstance.GetLight(0).mPosition);
effect.Parameters["lightpos1"].SetValue(LightingManager.pInstance.GetLight(1).mPosition);
effect.Parameters["lightpos2"].SetValue(LightingManager.pInstance.GetLight(2).mPosition);
effect.Parameters["lightcol0"].SetValue(LightingManager.pInstance.GetLight(0).mColor);
effect.Parameters["lightcol1"].SetValue(LightingManager.pInstance.GetLight(1).mColor);
effect.Parameters["lightcol2"].SetValue(LightingManager.pInstance.GetLight(2).mColor);
}
}
mesh.Draw();
}