texture blending problem

akuehn3000

Newcomer
Joined
Jan 29, 2004
Messages
18
I´m trying to use texture blending with the textures from the mfctex sample.
With the following code the first texture gets just darkened instead of
being illuminated like
the lightmap. Does anyone has any idea what´s wrong?

device.SetTexture(0,brickTexture);

device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;

device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;


device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;

device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;

device.TextureState[0].ResultArgument = TextureArgument.Current;


device.SetTexture(1,spotlightTexture);

device.TextureState[1].ColorOperation = TextureOperation.Modulate;

device.TextureState[1].ColorArgument1 = TextureArgument.TextureColor;

device.TextureState[1].ColorArgument2 = TextureArgument.Current;

device.TextureState[1].AlphaOperation = TextureOperation.Disable;

device.TextureState[1].ResultArgument = TextureArgument.Current;

meshc.DrawSubset(0);
 
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