|
网上关于用HLSL渲染蒙皮骨骼动画的例子很少,能参考的只有微软的示例程序,有些地方看不太懂,有高手能指教下么?
这是部分代码:
VS_OUTPUT VertSkinning( VS_INPUT i, uniform int iNumBones )
{
VS_OUTPUT o;
float3 Pos = 0.0f;
float3 Normal = 0.0f;
float LastWeight = 0.0f;
// skin VB inputs
VS_SKIN_INPUT vsi = { i.Pos, i.BlendWeights, i.BlendIndices, i.Normal };
VS_SKIN_OUTPUT vso = VS_Skin( vsi, iNumBones );
// transform position from world space into view and then projection space
o.Pos = mul( float4( vso.vPos.xyz, 1.0f ), g_mViewProj );
// normalize normals
Normal = normalize( vso.vNor );
// Shade (Ambient + etc.)
o.Diffuse = float4( MaterialAmbient.xyz + saturate( dot( Normal, lhtDir.xyz ) ) * MaterialDiffuse.xyz, 1.0 );
// copy the input texture coordinate through
o.Tex0 = i.Tex0.xy;
return o;
}
int CurNumBones = 2;
VertexShader vsArray20[ 4 ] = { compile vs_2_0 VertSkinning( 1 ),
compile vs_2_0 VertSkinning( 2 ),
compile vs_2_0 VertSkinning( 3 ),
compile vs_2_0 VertSkinning( 4 ) };
骨骼数(染色板?)是可以通过参数输入的,为什么还要设置这个渲染器数组,而且还事先把骨骼数赋值
technique Skinning20
{
pass p0
{
VertexShader = ( vsArray20[ CurNumBones ] );
PixelShader = compile ps_2_0 PixScene();
}
}
这例子看了一星期没看懂,有高手能指教下么 |
|