Jump to content
  • Advertisement
Sign in to follow this  
conman

direct3d 9 multitexturing

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Yesterday I thought that I go my multitexturing working, but that was not quite true... There is still one last problem: The device ignores my 2nd set of texture coords. Here are the relevant parts:
public struct PositionMultitex2
{
    public Vector3 Position;
    public  float Tu0, Tv0;
    public  float Tu1, Tv1;
 
    public static readonly VertexFormats Format = VertexFormats.Position |  VertexFormats.Texture0 | VertexFormats.Texture1;

    public PositionMultitex2(ref Vector3 pos, ref Vector2 tex0, ref Vector2 tex1 )
    {
      this.Position = pos;
      this.Tu0 = tex0.X;
      this.Tv0 = tex0.Y;
      this.Tu1 = tex1.X;
      this.Tv1 = tex1.Y;
    }
}

...

device.VertexFormat = CustomVertex.PositionMultitex2.Format;

device.SetTexture( 0, this.textures[face.TextureID] );
device.SetTexture( 1, this.lightmaps[face.LightmapID] );

device.SetTextureStageState( 0, TextureStageStates.TextureCoordinateIndex, 0);          
device.SetTextureStageState( 0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);		
device.SetTextureStageState( 0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1);
           

device.SetTextureStageState( 1, TextureStageStates.TextureCoordinateIndex, 1);
device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor);		
device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.Current);		
device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Modulate);		

device.DrawUserPrimitives(PrimitiveType.TriangleFan, verts.Length-2, verts);

I am pretty sure that everything works well except that the 2d texture set is always (0,0) (the texture coords provided in the vertex array are all right) I searched the web for hours now but found no explanation Any ideas? Constantin

Share this post


Link to post
Share on other sites
Advertisement
Perhaps someone knows how to debug something like this - I mean where the info in the vertices goes or not goes.
I am new to DirectX as you see :)

Thanks,
Constantin

[Edited by - conman on May 23, 2005 2:54:22 AM]

Share this post


Link to post
Share on other sites
The flag that specifies texture coordinates in your vertex format does not work like you may think (and this is a quite common mistake). The TextureX flag gives the number of texture coordinates in your vertex format. So instead of

public static readonly VertexFormats Format = VertexFormats.Position |
VertexFormats.Texture0 | VertexFormats.Texture1;

use

public static readonly VertexFormats Format = VertexFormats.Position |
| VertexFormats.Texture2;


Greetz,

Illco

PS: this is the case for C++ and I think VB; I'm not sure about C# but on the other hand MS tended to keep the interface as similar as possible.

Share this post


Link to post
Share on other sites
Many many thanks Illco!

I never would have thought of that, especially because there is plenty of source code in the web doing this wrong!!

I guess they have to give a little more information on these topics in the D3D docs...

Cheers,
Constantin

Share this post


Link to post
Share on other sites
Quote:
Original post by conman
Many many thanks Illco!

I never would have thought of that, especially because there is plenty of source code in the web doing this wrong!!

I guess they have to give a little more information on these topics in the D3D docs...

You should've paid attention to the FVF I wrote here [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!