Sign in to follow this  

HLSL, ID3DXMesh and Vertex Declarations

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I have made a vertex shader to be used for toon shading. It works allright with a ID3DXMesh created with D3DXCreateTeapot. However, when I try to render a hand-built ID3DXMesh, it doesn't get cell-shaded! Here's the mesh creation code :
// Mesh is a ID3DXMesh **

D3DXCreateMeshFVF(NumIndices,NumVertices,D3DXMESH_MANAGED | D3DXMESH_WRITEONLY,SVertex::FVF,Device,Mesh);
//SVertex::FVF == (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1)

//fill vertices/indices/attribute allright

D3DXComputeNormals((*Mesh),NULL);



and I render using DrawSubset(); I think that the problem is that:
D3DXCreateTeapot makes a D3DFVF_XYZ | D3DFVF_NORMAL
My code          makes a D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1
while the vertex shader requires:
struct VS_INPUT
{
    vector position : POSITION;
    vector normal   : NORMAL;
};
My best guess is that I should build a vertex declaration and apply it to the device before rendering (when using HLSL). My second guess is that I shouldn't use D3DXCreateMeshFVF because HLSL works with vertex declarations. So, can anyone help me please?

Share this post


Link to post
Share on other sites
Yes, the D3DXCreate* functions don't compute texture coordinants. You will have to load your own mesh. However, your sample code looks like it should work, but I haven't programmed with shader for a while.

Share this post


Link to post
Share on other sites

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this