mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Fixed albedo not working when first importing asset
This commit is contained in:
@@ -83,7 +83,7 @@ Ref<File> GLTFBaker::Bake(const Ref<File>& file)
|
||||
material = CreateRef<Material>();
|
||||
if (!materialData.albedo.empty())
|
||||
{
|
||||
material->SetAlbedo(absolutePath + "/../" + materialData.albedo);
|
||||
material->SetAlbedo(FileSystem::AbsoluteToRelative(absolutePath + "/../" + materialData.albedo));
|
||||
}
|
||||
|
||||
if (!materialData.normal.empty())
|
||||
@@ -117,7 +117,7 @@ Ref<File> GLTFBaker::Bake(const Ref<File>& file)
|
||||
materialCache[materialPath] = material;
|
||||
}
|
||||
|
||||
mesh->MaterialResource = RID(material->ID);
|
||||
mesh->SetMaterial(material);
|
||||
model->AddMesh(std::move(mesh));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,21 @@ namespace Nuake
|
||||
inline bool GetUnlit() { return data.u_Unlit == 1; }
|
||||
|
||||
bool HasAlbedo() { return (m_Albedo != nullptr || AlbedoImage != UUID(0)); }
|
||||
void SetAlbedo(const std::string path) { m_Albedo = CreateRef<Texture>(path); }
|
||||
void SetAlbedo(const std::string path)
|
||||
{
|
||||
if (FileSystem::FileExists(path))
|
||||
{
|
||||
GPUResources& resources = GPUResources::Get();
|
||||
Ref<VulkanImage> image = CreateRef<VulkanImage>(FileSystem::RelativeToAbsolute(path));
|
||||
if (resources.AddTexture(image))
|
||||
{
|
||||
AlbedoImage = image->GetID();
|
||||
}
|
||||
|
||||
Ref<Texture> albedoTexture = TextureManager::Get()->GetTexture(path);
|
||||
SetAlbedo(albedoTexture);
|
||||
}
|
||||
}
|
||||
void SetAlbedo(Ref<Texture> texture) { m_Albedo = texture; }
|
||||
|
||||
bool HasAO() { return m_AO != nullptr; }
|
||||
|
||||
Reference in New Issue
Block a user