Texture Coordinate Generation ?

Started by
2 comments, last by rahulpawar 13 years, 2 months ago
Question 1 :

Texture coordinates can be supplied by the geometry, or can be automatically generated using Direct3D texture coordinate generation (which is an advanced feature).

I have Vertex buffer filled with

struct TexVert
{
vector3D position;
vector3D normal;

vector2D UV; // Only one Tex coordinate provided
};

i have a base texture already applied, now i want to apply another layer of texture above the base texture say something like decal or bullet shots or something continuously scrolling.

now i know there is multitexturing involved but i can't figure out how to provide for texcoords for that other layer

I know this can be done using shaders but i want to implement this using fixed function pipeline like using SetTextureStage and SetTransform => TextureTransform...


does any one know how to do it ?

Question 2 :

if i do this type of multitexturing using fixed function pipeline (i.e. SetTextureStage) can i still be able to use shaders for different effect and retain what i have achieved using fixed function pipeline While working on same frame.
Advertisement
This is what your new TexVert struct should look like after adding another set of UV coordinates:
struct TexVert
{
vector3D position;
vector3D normal;

vector2D UV[2];
};

Alternatively you can do something like this in your struct instead:
vector2D UV0;
vector2D UV1;
But I prefer array notation for multiple texcoords.

Also, change your FVF from (old one texcoord): (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1)
to (new two texcoords): (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(1) | D3DFVF_TEX2)

Then when you want to set the transforms for each texture coordinate set, you use (assuming m_dev is the name of your LPDIRECT3DDEVICE9):
m_dev->SetTransform(D3DTS_TEXTURE0, &transform0);
m_dev->SetTransform(D3DTS_TEXTURE1, &transform1);

To answer your question 2, I'm not exactly sure if you're able to mix the programmable pipeline with multitexturing. But I am pretty sure that such a practice is frowned upon if it is possible, since if you are using shaders in the first place, it's relatively trivial to implement your own version of multitexturing in a shader.
Hey Thanks for replying,

OK now i know that Fixed Function and shaders should not be mixed... so i would probably put check to either allow Fixed Function or shaders...

But regarding my Question No. 1 i know how to add a second set of tex coords and use the transforms BUT i wanted to know how to automatically generate new set of tex coords...Tutorials...example code...etc

Here's the Link it say it is an advanced function introduced in Directx 9...

Here i want to add the point that I'm supposed to implement the renderer using Directx 9 only.
guyzz please some help here !!!! :o

This topic is closed to new replies.

Advertisement