@@ -293,7 +293,7 @@ void Mesh::InitSampler(D3D12* renderer) {
293293 UINT nNumORMTextures = this ->m_ORMTextures .size ();
294294 this ->m_cbv_srvHeap ->Allocate (nNumTextures + nNumORMTextures);
295295 UINT nLastIndex = m_cbv_srvHeap->GetLastDescriptorIndex ();
296- UINT nFirstIndex = nLastIndex - nNumTextures;
296+ UINT nFirstIndex = nLastIndex - ( nNumTextures + nNumORMTextures) ;
297297
298298 UINT nActualIndex = nFirstIndex;
299299 for (std::pair<UINT, ComPtr<ID3D12Resource>> resource : this ->m_textures ) {
@@ -351,6 +351,8 @@ void Mesh::LoadModel(std::string filename) {
351351 return ;
352352 };
353353
354+ UINT nIndex = 0 ;
355+
354356 Assimp::Importer importer;
355357 const aiScene* scene = importer.ReadFile (filename, NULL );
356358
@@ -401,12 +403,14 @@ void Mesh::LoadModel(std::string filename) {
401403
402404 aiString texPath;
403405 aiString metalPath;
406+ nIndex++;
404407 if (material->GetTextureCount (aiTextureType_BASE_COLOR) > 0 && material->GetTexture (aiTextureType_DIFFUSE, 0 , &texPath) == AI_SUCCESS) {
405408 const aiTexture* texture = scene->GetEmbeddedTexture (texPath.C_Str ());
406409 if (texture != nullptr ) {
407410 ResourceManager* resMgr = ResourceManager::GetInstance ();
411+ std::string name = std::string (texPath.C_Str ());
408412 ComPtr<ID3D12Resource> resource;
409- resMgr->LoadTexture ((BYTE*)texture->pcData , texture->mWidth , texture-> mFilename . C_Str () , resource);
413+ resMgr->LoadTexture ((BYTE*)texture->pcData , texture->mWidth , name , resource);
410414 resource->SetName (L" Mesh Base color" );
411415 this ->m_textures [i] = resource;
412416 }
@@ -417,8 +421,9 @@ void Mesh::LoadModel(std::string filename) {
417421
418422 if (texture != nullptr ) {
419423 ResourceManager* resMgr = ResourceManager::GetInstance ();
424+ std::string name = std::string (metalPath.C_Str ());
420425 ComPtr<ID3D12Resource> resource;
421- resMgr->LoadTexture ((BYTE*)texture->pcData , texture->mWidth , texture-> mFilename . C_Str () , resource);
426+ resMgr->LoadTexture ((BYTE*)texture->pcData , texture->mWidth , name , resource);
422427 resource->SetName (L" Mesh Metallic Roughness" );
423428 this ->m_ORMTextures [i] = resource;
424429 }
0 commit comments