• Advertisement
Sign in to follow this  

HLSL - Multiple World Matrices

This topic is 2211 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

I'm using VB.NET and DirectX9 to animate a mesh. The following code is the Draw function:

[CODE]
p = FX.Begin(Direct3D.FX.None)
For k = 0 To p - 1
FX.BeginPass(k)
For iattrib As Integer = 0 To mesh.NumberAttributes - 1
Dim boneCombo As BoneCombination = mesh.BoneTable(iattrib)
For i As Integer = 0 To mesh.NumberInfluences - 1
Dim matrixIndex As Integer = boneCombo.BoneId(i)
If matrixIndex <> -1 Then
Dim tempMatrix As Matrix = offsetMatrices(matrixIndex) * frameMatrices(matrixIndex).Combined
'DXDEV.Transform.SetWorldMatrixByIndex(i, tempMatrix)
'''''''''''''''''''''
End If
Next
DXDEV.RenderState.VertexBlend = DirectCast(boneCombo.BoneId.Length, VertexBlend) - 1
mesh.MeshData.Mesh.DrawSubset(iattrib)
Next
FX.EndPass()
Next k
FX.End()
[/CODE]

As you can see there are multiple world matrices that are passed in different indexes in device. The thing is that I use an HLSL effect file to render the mesh and I don't know how to pass and use multiple world matrices in my effect. I want to replace the commented line:

[CODE]
DXDEV.Transform.SetWorldMatrixByIndex(i, tempMatrix)
[/CODE]

with a line that passes those world matrices in my effect and then some HLSL code to use those world matrices in my vertex shader.

Any help will be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
An Effect should have a method for setting an array of matrices, which is what you'll want to use. Skinning with shaders can be tricky...I would suggest looking at the skinning samples in the DirectX SDK for some guidance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement