Archived

This topic is now archived and is closed to further replies.

aphydx

skin mesh shadows

Recommended Posts

aphydx    100
i'm trying to implement shadow volumes via the method described in the dx sdk .. however, i don't know how to mesh this with my implementation of skin meshes .. here is my skin mesh vertex blending code .. any suggestions on how i can go about this?
    
void CMesh::Render(LPDIRECT3DDEVICE9 pD3DDevice)
{
  if(mNumBones > 0)
  {
    LPD3DXBONECOMBINATION tBoneCombo = (LPD3DXBONECOMBINATION)mBoneCombo->GetBufferPointer();
    D3DXMATRIX tTempMtx;

    for(DWORD i = 0; i < mNumAttr; i++)
    {
      DWORD tNumBlend = 0;
      for(DWORD j = 0; j < mNumInfl; j++)
        if(tBoneCombo[i].BoneId[j] != UINT_MAX)
          tNumBlend = j;


      // set world matrices

      DWORD tID;
      for(DWORD j = 0; j < mNumInfl; j++)
      {
        tID = tBoneCombo[i].BoneId[j];
        if(tID != UINT_MAX)
        {
          D3DXMatrixMultiply(&tTempMtx, &mBoneOffset[tID], mBones[tID]);
          pD3DDevice->SetTransform(D3DTS_WORLDMATRIX(j), &tTempMtx);
        }
      }


      // set material & texture

      if(i == 0 || (tBoneCombo[i].AttribId != tBoneCombo[i - 1].AttribId))
      {
        pD3DDevice->SetMaterial(&mMaterials[tBoneCombo[i].AttribId]);
        pD3DDevice->SetTexture(0, mTextures[tBoneCombo[i].AttribId]);
      }

      pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, tNumBlend);
      mBlendMesh->DrawSubset(i);
    }

    pD3DDevice->SetRenderState(D3DRS_VERTEXBLEND, 0);
  }
  else for(DWORD i = 0; i < mNumMaterials; i++)
  {
    pD3DDevice->SetMaterial(&mMaterials[i]);
    pD3DDevice->SetTexture(0, mTextures[i]);
    mMesh->DrawSubset(i);
  }
}
  
[edited by - aphydx on March 18, 2003 1:08:09 PM]

Share this post


Link to post
Share on other sites
thedo    124
I attempted something like you decribe (I havent looked at you code much - I used non indexed blending (which was fastest on my GF4)). With the resultant LPD3DXMESH I got the VB and performed the shadow operations (as per the shadow volume example). It was pretty slow so I didnt investigate any further. Only took about a night of coding to implement so experiment and you may get it workable.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

[edited by - thedo on March 19, 2003 3:28:19 PM]

Share this post


Link to post
Share on other sites
hello2k1    122
The book, "Real-Time Rendering Tricks and Techniques in DirectX", presented an interesting alternative to Microsoft''s shadow volume technique. How about you try extruding the shadow using a vertex shader as apposed to making a brand new mesh? This should work especially well on a gf4 (Ti?).

Hope that helped.
-Rob

Share this post


Link to post
Share on other sites