Transforming texture coords while using transformed vertices

Transforming texture coords while using transformed vertices

Post by Pavel Cernohorsk » Wed, 02 Jul 2003 06:14:28



I have this problem. I'using flexible vertex format
(D3DFVF_XYZRHW | D3DFVF_TEX1) with transformed vertices.
My vertex definition is

struct VERTEX {
FLOAT X, Y, Z, RHW; //transformed position for the vertex
FLOAT TU, TV; //texture coords

Quote:};

but I need to use multitexturing with second texture
transformed by matrix. I hoped that I will use

Direct3DDevice->SetTextureStageState(1,
D3DTSS_TEXCOORDINDEX, 1);
Direct3DDevice->SetTextureStageState(1,
D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
Direct3DDevice->SetTransform(D3DTS_TEXTURE1, &Matrix);

but DX seems not to transform second texture (ignore my
transformation matrix), probably becouse i'm using
D3DFVF_XYZRHW - transformed vertices. Is this corect? How
can I avoid this problem and force DX to transform my
texture, although i use transformed vertices?
Thanks for help,
Pavel Cernohorsky.

 
 
 

Transforming texture coords while using transformed vertices

Post by Pavel Cernohorsk » Wed, 02 Jul 2003 19:59:22


OK, now I found note in DX documentation, that
transformed and lit vertices cannot use texture
transformation, but I have diferent question - how to
perferm this transformation manualy? How to transform my
texture coords by given matrix? I tried
D3DXVec2TransformCoord, but it didn't work.
Thanks for help,
Pavel Cernohorsky

Quote:>-----Original Message-----
>I have this problem. I'using flexible vertex format
>(D3DFVF_XYZRHW | D3DFVF_TEX1) with transformed vertices.
>My vertex definition is

>struct VERTEX {
>FLOAT X, Y, Z, RHW; //transformed position for the vertex
>FLOAT TU, TV; //texture coords
>};

>but I need to use multitexturing with second texture
>transformed by matrix. I hoped that I will use

>Direct3DDevice->SetTextureStageState(1,
>D3DTSS_TEXCOORDINDEX, 1);
>Direct3DDevice->SetTextureStageState(1,
>D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
>Direct3DDevice->SetTransform(D3DTS_TEXTURE1, &Matrix);

>but DX seems not to transform second texture (ignore my
>transformation matrix), probably becouse i'm using
>D3DFVF_XYZRHW - transformed vertices. Is this corect?
How
>can I avoid this problem and force DX to transform my
>texture, although i use transformed vertices?
>Thanks for help,
>Pavel Cernohorsky.
>.


 
 
 

Transforming texture coords while using transformed vertices

Post by Eyal Tele » Thu, 03 Jul 2003 19:37:12


Instead of using transformed vertices, you can use an orthogonal
projection or identify matrices. If you use a "projection"
transformation that just scales your XY coordinates from screen coords
to [-1,1]x[-1,1], you can keep the same XY coords you have now.

        Eyal


> I have this problem. I'using flexible vertex format
> (D3DFVF_XYZRHW | D3DFVF_TEX1) with transformed vertices.
> My vertex definition is

> struct VERTEX {
> FLOAT X, Y, Z, RHW; //transformed position for the vertex
> FLOAT TU, TV; //texture coords
> };

> but I need to use multitexturing with second texture
> transformed by matrix. I hoped that I will use

> Direct3DDevice->SetTextureStageState(1,
> D3DTSS_TEXCOORDINDEX, 1);
> Direct3DDevice->SetTextureStageState(1,
> D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
> Direct3DDevice->SetTransform(D3DTS_TEXTURE1, &Matrix);

> but DX seems not to transform second texture (ignore my
> transformation matrix), probably becouse i'm using
> D3DFVF_XYZRHW - transformed vertices. Is this corect? How
> can I avoid this problem and force DX to transform my
> texture, although i use transformed vertices?
> Thanks for help,
> Pavel Cernohorsky.