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

HLSL - Multiple World Matrices

Started by Zosimas Dec 30, 2011 at 9:08 PM 0 replies 1.2k views
Original Post
Zosimas
Zosimas
I'm using VB.NET and DirectX9 to animate a mesh. The following code is the Draw function:


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()


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:


DXDEV.Transform.SetWorldMatrixByIndex(i, tempMatrix)


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.
MJP
MJP
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.

Topic Locked

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

Sign in to reply to this topic.