| 1025 | } |
| 1026 | |
| 1027 | void Model::LoadMaterialResources(MeshMaterial& material, const wstring& directory, ID3D11Device* device, bool forceSRGB) |
| 1028 | { |
| 1029 | // Load the diffuse map |
| 1030 | wstring diffuseMapPath = directory + material.DiffuseMapName; |
| 1031 | if(material.DiffuseMapName.length() > 1 && FileExists(diffuseMapPath.c_str())) |
| 1032 | material.DiffuseMap = LoadTexture(device, diffuseMapPath.c_str(), forceSRGB); |
| 1033 | else |
| 1034 | { |
| 1035 | static ID3D11ShaderResourceViewPtr defaultDiffuse; |
| 1036 | if(defaultDiffuse == nullptr) |
| 1037 | defaultDiffuse = LoadTexture(device, L"..\\Content\\Textures\\Default.dds"); |
| 1038 | material.DiffuseMap = defaultDiffuse; |
| 1039 | } |
| 1040 | |
| 1041 | // Load the normal map |
| 1042 | wstring normalMapPath = directory + material.NormalMapName; |
| 1043 | if(material.NormalMapName.length() > 1 && FileExists(normalMapPath.c_str())) |
| 1044 | material.NormalMap = LoadTexture(device, normalMapPath.c_str()); |
| 1045 | else |
| 1046 | { |
| 1047 | static ID3D11ShaderResourceViewPtr defaultNormalMap; |
| 1048 | if(defaultNormalMap == nullptr) |
| 1049 | defaultNormalMap = LoadTexture(device, L"..\\Content\\Textures\\DefaultNormalMap.dds"); |
| 1050 | material.NormalMap = defaultNormalMap; |
| 1051 | } |
| 1052 | |
| 1053 | // Load the roughness map |
| 1054 | wstring roughnessMapPath = directory + material.RoughnessMapName; |
| 1055 | if(material.RoughnessMapName.length() > 1 && FileExists(roughnessMapPath.c_str())) |
| 1056 | material.RoughnessMap = LoadTexture(device, roughnessMapPath.c_str()); |
| 1057 | else |
| 1058 | { |
| 1059 | static ID3D11ShaderResourceViewPtr defaultRoughnessMap; |
| 1060 | if(defaultRoughnessMap == nullptr) |
| 1061 | defaultRoughnessMap = LoadTexture(device, L"..\\Content\\Textures\\DefaultRoughness.dds"); |
| 1062 | material.RoughnessMap = defaultRoughnessMap; |
| 1063 | } |
| 1064 | |
| 1065 | // Load the metallic map |
| 1066 | wstring metallicMapPath = directory + material.MetallicMapName; |
| 1067 | if(material.MetallicMapName.length() > 1 && FileExists(metallicMapPath.c_str())) |
| 1068 | material.MetallicMap = LoadTexture(device, metallicMapPath.c_str()); |
| 1069 | else |
| 1070 | { |
| 1071 | static ID3D11ShaderResourceViewPtr defaultMetallicMap; |
| 1072 | if(defaultMetallicMap == nullptr) |
| 1073 | defaultMetallicMap = LoadTexture(device, L"..\\Content\\Textures\\DefaultBlack.dds"); |
| 1074 | material.MetallicMap = defaultMetallicMap; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | } |
nothing calls this directly
no test coverage detected