diff --git a/Nuake/Source/Nuake/Rendering/Textures/Material.h b/Nuake/Source/Nuake/Rendering/Textures/Material.h index 510357f3..6f1ed2e4 100644 --- a/Nuake/Source/Nuake/Rendering/Textures/Material.h +++ b/Nuake/Source/Nuake/Rendering/Textures/Material.h @@ -138,6 +138,26 @@ namespace Nuake } // TODO others. + if (NormalImage != 0) + { + j["NormalImage"] = static_cast(NormalImage); + } + + if (RoughnessImage != 0) + { + j["RoughnessImage"] = static_cast(RoughnessImage); + } + + if (MetalnessImage != 0) + { + j["MetalnessImage"] = static_cast(MetalnessImage); + } + + if (AOImage != 0) + { + j["AOImage"] = static_cast(AOImage); + } + if (HasAlbedo()) { j["Albedo"] = this->m_Albedo->Serialize(); @@ -189,6 +209,26 @@ namespace Nuake AlbedoImage = static_cast(j["AlbedoImage"]); } + if (j.contains("NormalImage")) + { + NormalImage = static_cast(j["NormalImage"]); + } + + if (j.contains("AOImage")) + { + AOImage = static_cast(j["AOImage"]); + } + + if (j.contains("RoughnessImage")) + { + RoughnessImage = static_cast(j["RoughnessImage"]); + } + + if (j.contains("MetalnessImage")) + { + MetalnessImage = static_cast(j["MetalnessImage"]); + } + if (j.contains("Albedo")) { const auto& texturePath = j["Albedo"]["Path"]; @@ -248,6 +288,7 @@ namespace Nuake { const auto& texturePath = j["Normal"]["Path"]; const std::string absolutePath = FileSystem::RelativeToAbsolute(texturePath); + if (FileSystem::FileExists(texturePath)) { GPUResources& resources = GPUResources::Get(); @@ -256,11 +297,18 @@ namespace Nuake { NormalImage = image->GetID(); } + + Ref normalTexture = TextureManager::Get()->GetTexture(absolutePath); + SetNormal(normalTexture); + } + else + { + GPUResources& resources = GPUResources::Get(); + Ref missingTexture = TextureManager::Get()->GetTexture2("missing_texture"); + NormalImage = missingTexture->GetID(); } - - Ref normalTexture = TextureManager::Get()->GetTexture(absolutePath); - SetMetalness(normalTexture); } + if (j.contains("AO")) {