Textureing Questions in D3D8
Hi
Got a few questions about textureing...
1. First one is about texture alignement, I did some search in the d3d8 help and found D3DTEXTUREADDRESS, seems like the solution to my problem is to set D3DTADDRESS_WRAP, if I dont want the texture to be stretched (sp). The help files tell what it is but dont how I set it, so that is what I need help with, and some information about aligning texture next to each other.
2. If I want to use more then 1 texture, should I create a
IDirect3DTexture8 *t1...*tN for every single texture OR use a IDirect3DTexture8 *Vt[number_of_textures] and load the textures in a for loop with
D3DXCreateTextureFromFile(pID3DDevice, filename, Vt);
and it would be fun to know if you 3d gurus out there are using this function to, or do you have your own BMP loading code?
3. When I got my textures loaded and everything, I was thinking something like this…
pID3DDevice->SetTexture(0, Vt[i++]);
draw_every_polygon_with_that_texture(i);
pID3DDevice->SetTexture(0, Vt[i++]);
draw_every_polygon_with_that_texture(i);
where the ''i'' might be a index in a vertex buffer or something like that
and, fhew long question, should I create a new Vertex buffer for every group of polygons that use a different texture?
The best answer is probaly that I should buy me a book about d3d8 <img src="smile.gif" width=15 height=15 align=middle> </i>
Hello,
1)
First off, your problem has nothing to do with the addressing mode, so leave that alone for now. If you want your texture to repeat, it''s all done with the vertices UV coordinates. If you use 0 - 1, your texture will stretch. If you use 0 - 2, the texture will repeat twice. If you use 0 - 0.5, you will get half of the texture. etc. So just mess with your triangle''s UV coordinates.
2)
What I do for my textures is create a linked list called TextureList which holds all textures loaded into the engine. When a model wants to load textures, for each texture, it first sees if it''s already in the list. If so, it grabs a pointer to it. If it doesn''t exist, I create it, and add it to the end of the texture list. Each triangle in a model has a pointer to a texture.
Then you can sort triangles by texture and render all of the triangles that use one texture before going to the next. It improves performance a LOT. After any experimentation stage, I wouldn''t even concider setting the texture per triangle, do it per triangle group (where a group is every triangle that uses a given texture).
Personally, I don''t use D3DX. I have my own module for loading bitmaps, and copying portions of bitmaps to texture memory. D3DX is much easier to use though, and works great.
1)
First off, your problem has nothing to do with the addressing mode, so leave that alone for now. If you want your texture to repeat, it''s all done with the vertices UV coordinates. If you use 0 - 1, your texture will stretch. If you use 0 - 2, the texture will repeat twice. If you use 0 - 0.5, you will get half of the texture. etc. So just mess with your triangle''s UV coordinates.
2)
What I do for my textures is create a linked list called TextureList which holds all textures loaded into the engine. When a model wants to load textures, for each texture, it first sees if it''s already in the list. If so, it grabs a pointer to it. If it doesn''t exist, I create it, and add it to the end of the texture list. Each triangle in a model has a pointer to a texture.
Then you can sort triangles by texture and render all of the triangles that use one texture before going to the next. It improves performance a LOT. After any experimentation stage, I wouldn''t even concider setting the texture per triangle, do it per triangle group (where a group is every triangle that uses a given texture).
Personally, I don''t use D3DX. I have my own module for loading bitmaps, and copying portions of bitmaps to texture memory. D3DX is much easier to use though, and works great.
"If you use 0 - 2, the texture will repeat twice. If you use 0 - 0.5, you will get half of the texture"
Dont think I got that part, now take the number 0.3, that would fit into all of the above, or?
Dont think I got that part, now take the number 0.3, that would fit into all of the above, or?
quote:Original post by ReiD
"If you use 0 - 2, the texture will repeat twice. If you use 0 - 0.5, you will get half of the texture"
Dont think I got that part, now take the number 0.3, that would fit into all of the above, or?
The U and V coordinates tell the coordinates of the texture.
U is for the X axis and V is for the Y axis.
0 means - The beginning of the texture and 1 means - The end of the texture.
So, if you use 0.5 as your U coordinate, you actually use half of your texture.
If you use U as 3, your texture will repeat itself 3 times (That is, only if your texture address is D3DTADDRESS_WRAP, which is by default).
0.3 will use about 1/3 of the texture.
- Goblineye Entertainment
The road to success is always under construction
well the D3DTADDRESS_WRAP seems to work on polygons that are the same size in X as in Y, but take a look at this picture
At the top on that thingy 10 polygons share those texture coordinates, dont know if thats why it looks really weird
If that picture in some way didnt work, here''s the url:
http://www2.ite.mh.se/~ping9903/textureproblem.jpg
At the top on that thingy 10 polygons share those texture coordinates, dont know if thats why it looks really weird
If that picture in some way didnt work, here''s the url:
http://www2.ite.mh.se/~ping9903/textureproblem.jpg
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement