texture blending problem

I finally found what the problem was. I forgot to set the texcoordindex for the second texture stage.
With the following code the lightmapping works fine (the lightmap is the cone lightmap from the mfctex example).

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer,Color.Black,1.0f,0);

device.BeginScene();

device.SetTexture(0,brickTexture);
device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;

device.SetTexture(1,spotlightTexture);

device.TextureState[1].TextureCoordinateIndex = 0;

device.TextureState[1].ColorOperation = TextureOperation.Modulate;
device.TextureState[1].ColorArgument1 = TextureArgument.TextureColor;
device.TextureState[1].ColorArgument2 = TextureArgument.Current;

device.TextureState[2].ColorOperation = TextureOperation.Disable;

meshc.DrawSubset(0);

device.EndScene();

device.Present();
 
Back
Top