posts - 72,  comments - 4,  trackbacks - 0
秦坦之旅的模型显示, 上个女主角祼模:

还有招唤出来的死灵:

通过pixwin分析模拟出来的对应的shader:
uniform matrix wvp;
uniform texture BaseTexture;
uniform texture BumpTexture;
sampler t = sampler_state
{
Texture = <BaseTexture>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
};
sampler b = sampler_state
{
Texture = <BumpTexture>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
};
static const int MAX_MATRICES = 48;
float4x4 g_boneMatrices[MAX_MATRICES] : WORLDMATRIXARRAY;
struct VS_IN
{   
float4 pos   : POSITION;
float2 tex : TEXCOORD0;
float3 Normal : NORMAL;
float4  BlendIndices : BLENDINDICES;
float4  BlendWeights : BLENDWEIGHT;
};
struct VS_OUT
{
    float4 pos : POSITION;
    float2 tex : TEXCOORD0;
};
//----------------------------------------------------------------------
VS_OUT VS( VS_IN vsIn )
{
VS_OUT vsOut;
int indices[4] = (int[4])vsIn.BlendIndices;
indices[0] = vsIn.BlendIndices.z*255;//vsIn.BlendIndices[2]*255;
indices[1] = vsIn.BlendIndices.y*255;//vsIn.BlendIndices[1]*255;
indices[2] = vsIn.BlendIndices.x*255;//vsIn.BlendIndices[0]*255;
indices[3] = vsIn.BlendIndices.w*255;//vsIn.BlendIndices[3]*255;
float weights[4] = (float[4])vsIn.BlendWeights;
float4 pos = 0.0f;
float4 bonepos = vsIn.pos;
bonepos.w = 1;
for ( int i = 0; i < 4; i++ )
{
pos += mul( bonepos, g_boneMatrices[indices[i]]) * weights[i];
  }
vsOut.pos = mul( pos, wvp );
vsOut.tex = vsIn.tex;
return vsOut;
}
struct PS_OUT
{
    float4 color : COLOR;
};
//----------------------------------------------------------------------
PS_OUT PS( VS_OUT psIn )
{
PS_OUT psOut;
  psOut.color = tex2D(t, psIn.tex);
//psOut.color = float4(1,1,1,1);
return psOut;
}
//----------------------------------------------------------------------
technique RenderMsh
{
    pass P0
    {
        VertexShader = compile vs_2_0 VS();
        PixelShader  = compile ps_2_0 PS();        
    } 
}
posted on 2013-12-27 17:58 flipcode 阅读(351) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理