I'm using Direct X 9 with the fixed pipeline (sorry should have mentioned that).
Here are the main render states:
device.SetRenderState(RenderState.ZEnable, true);
device.SetRenderState(RenderState.ZWriteEnable, true);
device.SetRenderState(RenderState.FillMode, FillMode.Solid);
device.SetRenderState(RenderState.FogEnable, false);
device.SetRenderState(RenderState.AlphaTestEnable, false);
device.SetRenderState(RenderState.NormalizeNormals, true);
device.SetRenderState(RenderState.Lighting, true);
device.SetRenderState(RenderState.SpecularEnable, false);
device.SetRenderState(RenderState.CullMode, Cull.Counterclockwise);
Lighting:
Light light = new Light();
light.Type = LightType.Point;
light.Diffuse = new Color4(1, 1, 1);
light.Ambient = new Color4(1, 1, 1);
light.Specular = new Color4(1, 1, 1);
light.Position = new Vector3(0, 0, -2);
light.Attenuation0 = 0;
light.Attenuation1 = 0.75f;
light.Attenuation2 = 0;
light.Range = 100;
device.SetLight(0, light);
device.EnableLight(0, true);
If I use the following blend states the sides turn white. The sides don't have a texture.
device.SetRenderState(RenderState.AlphaBlendEnable, true);
device.SetRenderState(RenderState.SourceBlend, Blend.SourceColor);
device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
device.SetTextureStageState(0, TextureStage.ColorOperation, TextureOperation.SelectArg1);
device.SetTextureStageState(0, TextureStage.ColorArg1, TextureArgument.Texture);
device.SetTextureStageState(0, TextureStage.ColorArg2, TextureArgument.Diffuse);
device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Disable);
device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture);
device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse);
And the rendering
for (int i = 0; i < m_materials.Length; i++)
{
device.Material = m_materials[i];
device.SetTexture(0, m_textures[i]);
m_mesh.DrawSubset(i);
}
I'm coming to the conclusion it has something to do with my blend states.