Sign in to follow this  
KanTeH

Indexed Vertex Blending not working ?

Recommended Posts

Im trying to use IndexedVertexBlending but when
i turn on DirectX-Debug on max outputlevel i get an error like:

Direct3D9: (ERROR) :Unsupported renderstate D3DRS_INDEXEDVERTEXBLENDENABLE.


When i use retail of DirectX there is no movment at all.

So isnt this supported from DirectX fixed functionpipeline? or is it my good old graphiccard.

Do i something wrong ? ....
pfff hard to get solved..... ahrd to get feeedback from directX






Share this post


Link to post
Share on other sites
Fixed function does not mean you can do anything it provides. You still have to check (by code or at least once for your card) if a feature is supported. To enable said state, MaxVertexBlendMatrixIndex of device caps has to be greater than 0. I never did skinning on my own, but just checked my card. Though it should run fine some F.Luna code doing something similar (which is only shader model 2.0, my card can take 3.0), it doesn't support this FFP functionality (in hardware vertex processing mode).

The DX docs also state that it should be supported by a device with software vertex processing. So at least you could check if your code works. Other device creation flags might or might not support it (Good luck!)

So it comes down to the question: Can you live with software vertex processing or does your card support shader model 2.0 and could you use shaders ?

(Disclaimer: As stated, never did skinning, maybe the shader model can be lesser for your needs).

Share this post


Link to post
Share on other sites


My cards support shader model 3.0 andcaps says
MaxVertexBlendMatrixIndex = 4
so this shouldnt be the problem.

Ive tried softwarevertexprocessing aswell and its failinn :(

Ill try to calc and draw each single vertex now to see if my matrices are ok which i pass to directX. If it works i could be sure the code behind works fine and i at least get a better feeling.

It works without indices and jsut one blendwight but not with indices.
Another idea what could be wrong is to set those indices. Im using this and im not sure if its maybe in wrong order ?!?

((PBYTE)(pData+ dwOffsetBlendIndice))[dwMatriceSlot-1] = nWorldMatriceIndex;

ty for help

Share this post


Link to post
Share on other sites
Hmmm, so my guess was off. And one really can't judge from that little code you provided if you are doing something wrong. On thing you could do is check against the DX SDK sample SkinnedMesh (it's got "all" vertex blend approaches). And I'd check the vertex structure, as far as I remember correctly for blending they have to be in a specific order, at least for FFP.

I just wonder if it's your mesh init which fails. A "not supported error" really sounded like a capability violation. Either it's not or I hit the wrong capability.

You need to show us more code. It's always good to show all relevant code that goes into a draw call (render states, vertex/index buffer or mesh update, vertex declaration, and of course the draw call). Also I suggest using PIX.

Share this post


Link to post
Share on other sites
Ive checked it with Pix but it gives only info about pos and normaldata per vertex. With code its a bit more complicated since i use a streamclass where u can add flags just like D3DFVXYZ |NORMAL | TEXTURE2 | TEXTURESIZE2
and then set it with functions like DATA_SetVerticeNormal(DWORD dwVerticeNumber,Vector vPos) etc...

But im sure about that the other code is correct since it worked with 1 BlendWeight and ive added Indices directly after the weights.

There might be a problem with
D3DFVF_XYZB5 and D3DFVF_LASTBETA_UBYTE4
and etc bla bla since they have rly hacked the the flags with that ;))
Im gona check it after i have checkd my other code with my debugdraw

Share this post


Link to post
Share on other sites
So you are using some third party class/lib to update the mesh. And it's using the "flexible" vertex format. In that case all fields must follow a specific order. Unfortunately the handy image was removed from the recent SDK docs and my google-fu is currently failing me, but here you are:



Looks like you have to do some reverse engineering of that stream class. I currently can only come up with the following idea: Get the vertex declaration from the mesh (e.g. using D3DXDeclaratorFromFVF) and check the field offsets against the offsets used for updating (dwOffsetBlendIndice et.al.).

Still: That error nags me. Does it appear when you use only one blend weight?

Share this post


Link to post
Share on other sites
This
"Direct3D9: (ERROR) :Unsupported renderstate D3DRS_INDEXEDVERTEXBLENDENABLE."
error happens only when i set DirectX on Debug
and use D3DCREATE_HARDWARE_VERTEXPROCESSING. Maybe Debug doesnt support this on HARDWARE which could make sense since it would be hard to get debug data.

Im currently trying to get it working with
Debugmode and D3DCREATE_SOFWARE_VERTEXPROCESSING, and there is no such error.

I use this to define my FVF:

Quote:
Code

dwFVF = D3DFVF_NORMAL;
dwCountBlendingWeights = 1;

switch (dwCountBlendingWeights)
{
case 0:
mDEBUG_RENDERDATA_dwFVF = dwFVF;
break;
case 1:
mDEBUG_RENDERDATA_dwFVF = dwFVF | D3DFVF_XYZB1 | D3DFVF_LASTBETA_UBYTE4;




Ive rewritet my streamclass with help of the function u gave me and
i get this vertexformat with
dwCountBlendingWeights = 1;
:
Quote:
Debugoutput
VElement:1 Stream:0 Offset:0 D3DDECLTYPE=D3DDECLTYPE_FLOAT3 D3DDECLMETHOD=D3DDECLMETHOD_DEFAULT D3DDECLUSAGE=D3DDECLUSAGE_POSITION D3DDECLUSAGE_INDEX:0
VElement:2 Stream:0 Offset:12 D3DDECLTYPE=D3DDECLTYPE_UBYTE4 D3DDECLMETHOD=D3DDECLMETHOD_DEFAULT D3DDECLUSAGE=D3DDECLUSAGE_BLENDINDICES D3DDECLUSAGE_INDEX:0
VElement:3 Stream:0 Offset:16 D3DDECLTYPE=D3DDECLTYPE_FLOAT3 D3DDECLMETHOD=D3DDECLMETHOD_DEFAULT D3DDECLUSAGE=D3DDECLUSAGE_NORMAL D3DDECLUSAGE_INDEX:0
VElement:4 Stream:255 Offset:0 D3DDECLTYPE=D3DDECLTYPE_UNUSED D3DDECLMETHOD=D3DDECLMETHOD_DEFAULT D3DDECLUSAGE=D3DDECLUSAGE_POSITION D3DDECLUSAGE_INDEX:0


This looks just fine for me.

When i now try to render it
i set the vertexdecleration and then set the renderstate with
Quote:
Code
switch (dwCountBlendingWeights)
{
case 0:
pDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
break;
case 1:
pDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_0WEIGHTS);
break;
case 2:
pDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_1WEIGHTS);
..


and then when i try to render it i get this error:
"Direct3D9: (ERROR) :The number of blend weights in the FVF should match what is set in D3DRS_VERTEXBLEND for indexed vertex blending"

which i dont understand since there are no weights and everythings looks just fine ...

Share this post


Link to post
Share on other sites
i googled this error and tryed to set directX to retail and its working :)

But when i use retail and turn to
D3DCREATE_HARDWARE_VERTEXPROCESSING or D3DCREATE_MIXED_VERTEXPROCESSING
it doesnt blend anything....

Ive checked MaxVertexBlendMatrixIndex again and im thing im wrong about this;)
since ive just seen MaxVertexBlendMatrix 255 i think.


Even if some cards might support BlendIndices.. i think ill try to sort the renderdata so i can draw it without indexedBlending or ill change to my own shaders but i dont like doing lightning and everything myself ;) not before my other stuffs are working nicly.

Do u know any good resources for shaddertutorials and lightning etc ?
Ive never used shadders yet :P

ty for reply

[Edited by - KanTeH on December 3, 2010 8:37:32 AM]

Share this post


Link to post
Share on other sites
So my initial guess wasn't that off after all ;)
Quote:
Do u know any good resources for shaddertutorials and lightning etc ?
Not directly. I always recommend F.Luna's Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach. It's got the basic 3D stuff covered (meshes, skinning, lighting, shadow map). It's not free, but it's worth it. All the code can be downloaded there.

Once you cope with shaders you will be glad to have changed from FFP: It's way less cryptic - and of course gives you greater flexibility.

By the way:
Quote:
"Direct3D9: (ERROR) :Unsupported renderstate D3DRS_INDEXEDVERTEXBLENDENABLE."
error happens only when i set DirectX on Debug


The error happens in retail, too, you just don't get that a conclusive feedback, just a failing HRESULT or something.

Share this post


Link to post
Share on other sites
Ok now ive writen (coppied partly :P ) a vertexshader for it.
My problem is now, it just runs in D3DCREATE_SOFTWARE_VERTEXPROCESSING mode. Again :((. Im sure its the vertexshader since if i dont set the framematrices it gives ;) chaos. When i put it on
D3DCREATE_HARDWARE_VERTEXPROCESSING mode, the mesh doesnt move.

So the problem have to be with the shader. How do i find the reason why it wont run?
The shader should use vs2.0 methods only, but my graphiccard supports vs3.0.

How u check if a shader should run on ur card ? Ill implenting some capchecks now, but how do i know if the shader for example runs to many instruction or so ?



[Edited by - KanTeH on December 4, 2010 5:15:07 PM]

Share this post


Link to post
Share on other sites
hi,
ive found my problem.
Since i was new to effect ive used the examplecode.

Quote:

dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
dwShaderFlags |= D3DXSHADER_NO_PRESHADER;



hR = D3DXCreateEffectFromFile(
mSERVICE_pD3Device,
cFilename.data(),
NULL, // CONST D3DXMACRO* pDefines,
NULL, // LPD3DXINCLUDE pInclude,
dwShaderFlags,
NULL, // LPD3DXEFFECTPOOL pPool,
&mEFFECT_pD3DXEffect,
NULL );


This force the shader to run in softwaredebugmode.
Ive replaced it with
dwShaderFlags = D3DXSHADER_SKIPVALIDATION;
and it runs :))



This topic is SOLVED :)
Ty for help!

Share this post


Link to post
Share on other sites

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