Jump to content

  • Log In with Google      Sign In   
  • Create Account

HLSL - Multiple World Matrices


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Zosimas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 30 December 2011 - 03:08 PM

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.

Sponsor:

#2 MJP   Moderators   -  Reputation: 11315

Like
0Likes
Like

Posted 30 December 2011 - 06:38 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS