Ability to define RMA texture in OBJ's MTL. (#39)
Add support for a map_RMA or map_ORM element in WaveFront MTL to provide an explicit name for the Roughness/Metalness/Ambient-occlusion texture name for PBR materials
This commit is contained in:
Родитель
32944e670c
Коммит
0533d0308f
|
@ -2017,6 +2017,18 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName, size_t nMaterials, cons
|
|||
*m2->EmissiveTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow RMA texture material property to override drived name
|
||||
if (!m0->rmaTexture.empty())
|
||||
{
|
||||
int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS,
|
||||
m0->rmaTexture.c_str(), -1,
|
||||
m2->RMATexture, MAX_TEXTURE_NAME, nullptr, FALSE);
|
||||
if (!result)
|
||||
{
|
||||
*m2->RMATexture = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
std::wstring normalTexture;
|
||||
std::wstring specularTexture;
|
||||
std::wstring emissiveTexture;
|
||||
std::wstring rmaTexture;
|
||||
|
||||
Material() noexcept :
|
||||
perVertexColor(false),
|
||||
|
|
|
@ -139,6 +139,7 @@ HRESULT LoadFromOBJ(
|
|||
{
|
||||
mtl.emissiveTexture = ProcessTextureFileName(it->strEmissiveTexture, dds);
|
||||
}
|
||||
mtl.rmaTexture = ProcessTextureFileName(it->strRMATexture, dds);
|
||||
|
||||
inMaterial.push_back(mtl);
|
||||
}
|
||||
|
|
|
@ -509,6 +509,12 @@ public:
|
|||
LoadTexturePath(InFile, curMaterial->strEmissiveTexture, MAX_PATH);
|
||||
curMaterial->bEmissive = true;
|
||||
}
|
||||
else if (0 == wcscmp(strCommand.c_str(), L"map_RMA")
|
||||
|| 0 == wcscmp(strCommand.c_str(), L"map_ORM"))
|
||||
{
|
||||
// RMA texture
|
||||
LoadTexturePath(InFile, curMaterial->strRMATexture, MAX_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unimplemented or unrecognized command
|
||||
|
@ -614,6 +620,7 @@ public:
|
|||
wchar_t strNormalTexture[MAX_PATH];
|
||||
wchar_t strSpecularTexture[MAX_PATH];
|
||||
wchar_t strEmissiveTexture[MAX_PATH];
|
||||
wchar_t strRMATexture[MAX_PATH];
|
||||
|
||||
Material() noexcept :
|
||||
vAmbient(0.2f, 0.2f, 0.2f),
|
||||
|
@ -628,7 +635,8 @@ public:
|
|||
strTexture{},
|
||||
strNormalTexture{},
|
||||
strSpecularTexture{},
|
||||
strEmissiveTexture{}
|
||||
strEmissiveTexture{},
|
||||
strRMATexture{}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче