Skip to main content
GameDev.net gamedev.net
🔒 Locked

SkinnedMesh sample

Started by Brisco Dec 27, 2004 at 5:06 AM 0 replies 550+ views
Original Post
Brisco
Brisco
Hello! I try to implement skinned meshes for character animation in my engine and I understand the theory behind it so far. I looked into the SDK SkinnedMesh sample and found the following code in the .fx file: static const int MAX_MATRICES = 26; float4x3 mWorldMatrixArray[MAX_MATRICES] : WORLDMATRIXARRAY; I'm not very experienced using HLSL, so my first question is: what exactly does WORLDMATRIXARRAY mean? I didn't find anything about it in the SDK documentation... but I think it is nothing else than the matrices set with the D3DTS_WORLDMATRIX(n) macro... well, if this is the case, I have some problem. I am currently working on a GeForce4 Ti4600 (until my GeForce6 arrives) and MaxVertexBlendMatrixIndex=0 on this card... so, it should not be possible to set 26 different world matrices and access it within a shader, or am I misunderstanding it? Next problem is, that I need some fallback version for pre-shader hardware. I thought of switching to software vertex processing for rendering of skinned meshes but don't know if this is really useful. I also asked myself how it is possible to use a different number of blend matrices for every vertex, i.e. 3 blend weights for vertex 1, 4 blend weights for vertex 2 without using VS 2.0 as described in "Skinned Mesh Character Animation with Direct3D 9.0c". Thank you for you help.
Aldenar
Aldenar
Hi,

The WORLDMATRIXARRAY is the array of bone matrices.

Actually, from a vertex shader, the values you can access are the VertexShaderConstants (See IDirect3DDevice9::SetVertexShaderConstantF). In vertex shader assembler, those are the c[n] (4 floats vector) registers. You have at least 96 of them on a VS 1.1 card, but you can find out the real number using D3DCAPS9::MaxVertexShaderConst. In that example, using 26 4x3 matrices requires 78 (26 * 3) constant registers, so it is possible ;)

If the hardware doesn't support all the features you need, yes, you can create a mixed device and switch software processing on and off. Another thing is that you can do software skinning and output the results to a dynamic vertex buffer on which you can use HW TnL to render. The former method can be useful when you need to render the exact same mesh a few times per frame (eg with shadow volumes).

It is a bit hard to have a variable weight count since VS 1.1 does not support conditional branching. But you can have a vertex format for 4 weights and set the ones you don't use for a given vertex to 0. That way you'll be able to have from 1 to 4 weights per vertex. The drawback is that you'll always process 4 weights even if the last 3 are 0.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.