I have a custom vertex structure

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

struct CUSTOM_VERTEX
{
FLOAT x, y, z, w;
DWORD color;
};

I create a vertex buffer for a single red triangle.
Then I render the primitive with vertex shader set to:
g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
Everything works fine.
But when I try to create my own vertex shader like this
DWORD dwDecl[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(D3DVSDE_BLENDWEIGHT , D3DVSDT_FLOAT4),
D3DVSD_REG(D3DVSDE_DIFFUSE, D3DVSDT_D3DCOLOR ),
D3DVSD_END()
};
g_pd3dDevice->CreateVertexShader( dwDecl, NULL, &m_hVertexShader, 0 );

My app crashes as it tryes to create vertex shader.
What do I do wrong? (same result with the D3DUSAGE_SOFTWAREPROCESSING).

And another question...
Where does vertex shader assembler come from?
What is this language? Does it produce code that my video card processor anderstand, or is it just microsoft invention and has nothing to do with hardware?
Please don't be mad for the C code. I swear I'll try to code it in asm as soon as it works in C.
Posted on 2002-12-05 04:32:31 by Vaxon
Afternoon, Vaxon.

Do a search of the DolphinVS example of Microsofts'. Use the words "D3DXAssembleShader" or "CreateVertexShader".

In that example, it uses vertex shaders for manipulating the Dolphin object.
~~~~~~~~~~~

One thing that you've got to remember is that, even though you're creating your own vertex shader, you still require the :
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

struct CUSTOM_VERTEX
{
FLOAT x, y, z, w;
DWORD color;
};

stuff:)

Depending upon your vid card, you will probably find that a programmable vertex shader can only be used in Hardware mode.

I have an example on my site called "Vertex-Shader.asm" (in the DX8.1 examples page) which uses programmable vertex shaders.

The language of the shader code is a form of RISC (IIRC "reduced instruction set cumthing").
Nothing like using two forms of assembly in the same proggy :grin: :alright:

Cheers,
Scronty
Posted on 2002-12-05 05:49:34 by Scronty
You should go to the vendor site of your graphic card.
There you will find a devkit which more than likely contains a shader compiler.
If you're lucky there will be a shader development application.

Note- You can load shaders from text files !!!

cya.
Posted on 2002-12-09 00:00:17 by Homer