游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2262|回复: 1

关于使用HLSL渲染蒙皮骨骼动画

[复制链接]

2

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2010-11-12 20:10:00 | 显示全部楼层 |阅读模式
网上关于用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();
    }
}
这例子看了一星期没看懂,有高手能指教下么

36

主题

100

帖子

725

积分

高级会员

Rank: 4

积分
725
发表于 2010-11-14 22:23:00 | 显示全部楼层

Re: 关于使用HLSL渲染蒙皮骨骼动画

这个CurNumBones是Weights Num,不是骨骼数。 每个顶点同时最多可以被4个矩阵去弯曲,每个矩阵对应一个weight(不过最后一个weight是用(1-前面所有weights)算出来的)。这里的CurNumBones要看你模型输出时每个顶点最大Weights Num来定。有不清楚的,你可以来觉醒3D论坛看看。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-5-30 12:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表