Jump to content
  • Advertisement

xxl534

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

102 Neutral

About xxl534

  • Rank
    Newbie
  1. I've set breakpoints and checked ,no error in compiling and shaders are non-NULL.Both shaders work seperately. And the SetMaterial is my habit,but it's not the key.
  2.  More complete code posted here. Notice line 44 to 47 line 44 and 45 are for vertex shader,46 and 47 are for pipeline.pipeline works,vertex shader has no effects. if((boneMesh->pSkinInfo!=NULL)) { //Set up bone transforms int numBones=boneMesh->pSkinInfo->GetNumBones(); for (int i = 0; i < numBones; i++) { D3DXMatrixMultiply(&currentBoneMatrices[i],&boneOffsetMatrices[i],pBoneMatrices[i]); } //Update the skinned mesh p_ct_VS_Skinning->SetMatrixArray(p_Device,h_VS_Skinning_MatrixPalette, currentBoneMatrices,numBones); //set matrix pallete in VertexShader for (int i = 0; i < boneMesh->numAttributeGroups; i++) { int mtrl=boneMesh->attributeTable[i].AttribId; p_Device->SetMaterial(&(boneMesh->materials[mtrl])); p_Device->SetTexture(texIndex,boneMesh->textures[mtrl]); p_Device->SetVertexShader(p_vs_Skinning); p_Device->SetPixelShader(p_ps_Simple); boneMesh->MeshData.pMesh->DrawSubset(mtrl); p_Device->SetVertexShader(NULL); p_Device->SetPixelShader(NULL); } } else if(boneMesh->pSkinInfo==NULL) { D3DXMATRIX world,position; p_Device->GetTransform(D3DTS_WORLD,&world); D3DXMatrixMultiply(&position,&bone->ConbinedTransformationMatrix,&world); p_Device->SetTransform(D3DTS_WORLD,&position); //For fixed-pipeline p_ct_VS_Simple->SetMatrix(p_Device,h_VS_Simple_WorldMatrix,&position); //For vertex shader p_Device->SetFVF(boneMesh->MeshData.pMesh->GetFVF()); for (int i = 0; i < boneMesh->NumMaterials; i++) { p_Device->SetMaterial(&(boneMesh->materials[i])); p_Device->SetTexture(texIndex,boneMesh->textures[i]); //p_Device->SetVertexShader(p_vs_Simple); //render by vertex shader //p_Device->SetPixelShader(p_ps_Simple); //render by vertex shader p_Device->SetVertexShader(NULL); //render by fixed-pipeline p_Device->SetPixelShader(NULL); //render by fixed-pipeline hr=boneMesh->MeshData.pMesh->DrawSubset(i); } p_Device->SetTransform(D3DTS_WORLD,&world); //for fixed-pipeline
  3. Thanks , I've tried to do so,but didn't make any difference.   I've not used SetVertexShader so I can't speak from experience (I use effects). However, it may be that you also have to release one vertex shader before setting and using another.
  4.      I have stayed up for this problem,but it is unsolved.      I load a D3DXFrame from an X file,Scan the D3DXFrame hierarchy and render the mesh if there is one.I have two vertexShader:p_vs_Skinning for the mesh-with-SkinInfo and p_vs_simple for the mesh-without-SkinInfo.There's no compile error or running-time error,two vertexShader perform perfect when running seperately.However, when they are simultaneously running,the p_vs_simple has no effect.Actually they were not literally simultaneous.they are in different parts of if-else branch.When I render mesh-without-SkinInfo through fixed pipeline ,it works well.When I bypass if branch,the vertexShader works.      Here's part of code,boneMesh is a derived class of D3DXMeshContainer,I've omitted large part of irrelevant content.Virtually I don't think the trouble is in the code. if((boneMesh->pSkinInfo!=NULL)) { for (int i = 0; i < boneMesh->numAttributeGroups; i++) { int mtrl=boneMesh->attributeTable[i].AttribId; p_Device->SetMaterial(&(boneMesh->materials[mtrl])); p_Device->SetTexture(texIndex,boneMesh->textures[mtrl]); p_Device->SetVertexShader(p_vs_Skinning); p_Device->SetPixelShader(p_ps_Simple); boneMesh->MeshData.pMesh->DrawSubset(mtrl); } } else { for (int i = 0; i < boneMesh->NumMaterials; i++) { p_Device->SetMaterial(&(boneMesh->materials[i])); p_Device->SetTexture(texIndex,boneMesh->textures[i]); p_Device->SetVertexShader(p_vs_Simple); p_Device->SetPixelShader(p_ps_Simple); boneMesh->MeshData.pMesh->DrawSubset(i); } }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!