Supporting multiples vertex formats
Hi,
I am currently working on my own 3dmodel formats (file and class/struct). However, I encountered the following design problem and I am seeking opinions about this since I don''t know what to do exactly. Also, maybe someone can point me to a better direction!
Let''s say I have a 3dmodel that uses vertices holding the following information:
X,Y,Z,
NX,NY,NZ,
TEX1_U,TEX1_V,
TEX2_U,TEX2_V // for multi-texturing
For hardware that supports multi-texturing, it''s all fine because I just load my 2 textures in 2 texture stages and pass the vertices above since I can set my FVF.
However, when I can''t use multi-texturing on hardware, I''ll need to separate the data into two sets of vertices (one for each texture) thus replicating a lot of data. I am wondering if it wouldn''t be better to make up on the fly 2 DX FVF vertices using my own vertex format (the one above) every time I need to render.
Thanks!
Can you use the same set of vertices? I just ask this, because it would be easy to do what you are asking by setting your texture stages.
Device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
This means to have your second texture stage read the second Tu and Tv. So if you have like
Vertice.xyz=Vector(50,50,50);
Vertice.Normal=Vector(0,0,-1):
Vertice.Tex1=Vector2d(1.0,0.0);
Vertice.Tex2=Vector2d)0.0,1.0);
The texture stage state would read from the second set!
Hope this helped!
Device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
This means to have your second texture stage read the second Tu and Tv. So if you have like
Vertice.xyz=Vector(50,50,50);
Vertice.Normal=Vector(0,0,-1):
Vertice.Tex1=Vector2d(1.0,0.0);
Vertice.Tex2=Vector2d)0.0,1.0);
The texture stage state would read from the second set!
Hope this helped!
Hi,
First of all, thanks for your reply...
Using multiple texture stages is only possible on hardware supporting more than 1 texture.
Maybe I need to specify that my mesh class is internally (to store the data) using a vertex format that''s matching the number of textures layer for the mesh... i.e. a mesh with 1 texture layer would use X,Y,Z,NX,NY,NZ,TEX1_U,TEX1_V while a mesh with 2 texture layer would use the same plus TEX2_U, TEX2_V. This implementation could be changed if needed of course...
My question is about how to deal with vertices data when falling back to multi-pass...
Should I "split" all meshes'' vertices defining 2 text. coord. sets into 2 "independant" vertex using each one 1 text. coor. set (thus duplicating a lot of data -> X,Y,Z,NX,NY,NZ)
OR
Should I keep my meshes'' vertices intact and make the needed FVF vertex to feed DirectX (a mesh vertex will "generate" 2 DX FVF vertex for 2 pass rendering).
Thanks!
First of all, thanks for your reply...
Using multiple texture stages is only possible on hardware supporting more than 1 texture.
Maybe I need to specify that my mesh class is internally (to store the data) using a vertex format that''s matching the number of textures layer for the mesh... i.e. a mesh with 1 texture layer would use X,Y,Z,NX,NY,NZ,TEX1_U,TEX1_V while a mesh with 2 texture layer would use the same plus TEX2_U, TEX2_V. This implementation could be changed if needed of course...
My question is about how to deal with vertices data when falling back to multi-pass...
Should I "split" all meshes'' vertices defining 2 text. coord. sets into 2 "independant" vertex using each one 1 text. coor. set (thus duplicating a lot of data -> X,Y,Z,NX,NY,NZ)
OR
Should I keep my meshes'' vertices intact and make the needed FVF vertex to feed DirectX (a mesh vertex will "generate" 2 DX FVF vertex for 2 pass rendering).
Thanks!
No, you are not getting the point!
You do not have to use multiple texture stages at all with what I told you!
You just do this
Device->SetTexture(1,Texture);
Device->DrawIndexedPrimitive();
This is only 1 texture pass!
You do not have to use multiple texture stages at all with what I told you!
You just do this
Device->SetTexture(1,Texture);
Device->DrawIndexedPrimitive();
This is only 1 texture pass!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement