Jump to content
  • Advertisement
Sign in to follow this  

HLSL, ID3DXMesh and Vertex Declarations

This topic is 4686 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);

//fill vertices/indices/attribute allright


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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!