Archived

This topic is now archived and is closed to further replies.

To_N

How to scale a Texture on a vertex?

Recommended Posts

Hi there struct VERTEX { float x,y,z; float nx,ny,nz; float tu,tv; }; #define FVF_VERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1) Thix is my FVF Vertex declaration. My question is now, how to scale a texture on thix vertex. u v coordinates work fine. Thx in advance... Tobias Noell / Germany

Share this post


Link to post
Share on other sites
Not sure if this is what you mean, but for my terrain, for example, if I want the texture to repeat three times, I do something like:

vertex->tu = x/(map_size/3);
vertex->tv = y/(map_size/3);

I guess, in essence, this is scaling the texture across the map by 33% (or so).

Share this post


Link to post
Share on other sites
Thanks for the fast answers, my problem was that i added values for all u and v coordinates af a polygon, which resultet as a texture shifting.
One last question:
How to scale, shift and rotate a texture, later i want to have 4 values, two for u/v shifting, two for u/v scaling and one for texture rotation, how to compute the u/v values for this?
Thx in advance

Tobias Noell / Germany

Share this post


Link to post
Share on other sites
If you''re wanting to offset, scale, and rotate the UVs on the fly (changing from frame to frame) you''ll probably not want to adjust the actual UVs. Instead, use a texture tranform.


pDevice->SetTransform(D3DTS_TEXTURE0, pMatrix);
pDevice->SetTextureStageState(D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);

Note that the matrix, despite being 4x4 is treated as 3x3 when using COUNT2, so you''re rotation would be roll, and translation would have to be placed in _31, and _32 manually instead of the standard _41, _42, _43 that the translation functions would use.

Share this post


Link to post
Share on other sites
Thx for your answer but I only need it to store once, so that the user can adjust these values once in my leveleditor and that an algorithm computes of the useres scale / rotation / shift coice the u v values. Any idea?

Share this post


Link to post
Share on other sites