Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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);

Posted

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();

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...