Sign in to follow this  
programmer_tom

cloning animated meshes for normal mapping

Recommended Posts

programmer_tom    214
hey all. i've recently fallen in love with normal maps on my static meshes and am trying to extend that to my animated meshes. works fine sometimes, but animations are messed up other times. I susect blendindices but cannot figure why. the base of the shader code is from the tiny sample. c++ looks like this: D3DVERTEXELEMENT9 decl[]= { { 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, { 0, 16, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 }, { 0, 32, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 }, { 0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, { 0, 48, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, { 0, 56, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, { 0, 68, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, D3DDECL_END() }; /*----------------------------------------------------------------*/ /* Clone each mesh using the new declaration with the tangent and */ /* binormal. */ /*----------------------------------------------------------------*/ LPD3DXMESH pMesh; if ( FAILED ( hr = m_pWorkingMesh->CloneMesh ( m_pWorkingMesh->GetOptions(), decl, CGameObject::GetD3DDevice(), &pMesh ) ) ) return hr; ...have d3d compute normals etc. hlsl shader structure looks like this: struct VS_INPUT_NORMAL_MAP { float4 vPos : POSITION; float3 vBlendWeights : BLENDWEIGHT; float4 vBlendIndices : BLENDINDICES; float3 vNormal : NORMAL; float2 vTex0 : TEXCOORD0; float3 vTangent : TANGENT; float3 vBinormal : BINORMAL; }; thanks -programmer_tom

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this