mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Fixed runtime compilation + GLTF material baking
This commit is contained in:
@@ -57,8 +57,10 @@ namespace Nuake
|
||||
return m_Indices;
|
||||
}
|
||||
|
||||
Ref<Material> Mesh::GetMaterial() const
|
||||
Ref<Material> Mesh::GetMaterial()
|
||||
{
|
||||
return MaterialResource.Get<Material>();
|
||||
|
||||
Ref<Material> material = ResourceManager::GetResource<Material>(MaterialResource.ID);
|
||||
if (!material)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nuake
|
||||
std::vector<Vertex>& GetVertices();
|
||||
std::vector<uint32_t>& GetIndices();
|
||||
|
||||
Ref<Material> GetMaterial() const;
|
||||
Ref<Material> GetMaterial();
|
||||
void SetMaterial(Ref<Material> material);
|
||||
|
||||
void Bind() const;
|
||||
|
||||
@@ -61,12 +61,12 @@ namespace Nuake
|
||||
}
|
||||
public:
|
||||
UUID AlbedoImage = UUID(0);
|
||||
UUID AOImage;
|
||||
UUID MetalnessImage;
|
||||
UUID RoughnessImage;
|
||||
UUID NormalImage;
|
||||
UUID AOImage = UUID(0);
|
||||
UUID MetalnessImage = UUID(0);
|
||||
UUID RoughnessImage = UUID(0);
|
||||
UUID NormalImage = UUID(0);
|
||||
|
||||
Ref<Texture> m_Albedo;
|
||||
Ref<Texture> m_Albedo;
|
||||
Ref<Texture> m_AO;
|
||||
Ref<Texture> m_Metalness;
|
||||
Ref<Texture> m_Roughness;
|
||||
@@ -130,6 +130,14 @@ namespace Nuake
|
||||
j["Path"] = Path;
|
||||
j["UUID"] = static_cast<uint64_t>(ID);
|
||||
j["HasAlbedo"] = this->HasAlbedo();
|
||||
|
||||
// new UUID
|
||||
if (AlbedoImage != 0)
|
||||
{
|
||||
j["AlbedoImage"] = static_cast<uint64_t>(AlbedoImage);
|
||||
}
|
||||
// TODO others.
|
||||
|
||||
if (HasAlbedo())
|
||||
{
|
||||
j["Albedo"] = this->m_Albedo->Serialize();
|
||||
@@ -176,6 +184,11 @@ namespace Nuake
|
||||
{
|
||||
ID = static_cast<uint64_t>(j["UUID"]);
|
||||
|
||||
if (j.contains("AlbedoImage"))
|
||||
{
|
||||
AlbedoImage = static_cast<uint64_t>(j["AlbedoImage"]);
|
||||
}
|
||||
|
||||
if (j.contains("Albedo"))
|
||||
{
|
||||
const auto& texturePath = j["Albedo"]["Path"];
|
||||
|
||||
@@ -60,29 +60,43 @@ Ref<File> GLTFBaker::Bake(const Ref<File>& file)
|
||||
|
||||
if(!materialData.albedo.empty())
|
||||
{
|
||||
material->SetAlbedo(materialData.albedo);
|
||||
material->SetAlbedo(absolutePath + "/../" + materialData.albedo);
|
||||
}
|
||||
|
||||
if(!materialData.normal.empty())
|
||||
{
|
||||
material->SetNormal(materialData.normal);
|
||||
material->SetNormal(absolutePath + "/../" + materialData.normal);
|
||||
}
|
||||
|
||||
if(!materialData.ao.empty())
|
||||
{
|
||||
material->SetAO(materialData.ao);
|
||||
material->SetAO(absolutePath + "/../" + materialData.ao);
|
||||
}
|
||||
|
||||
if(!materialData.metallic.empty())
|
||||
{
|
||||
material->SetMetalness(materialData.metallic);
|
||||
material->SetMetalness(absolutePath + "/../" + materialData.metallic);
|
||||
}
|
||||
|
||||
if(!materialData.roughness.empty())
|
||||
{
|
||||
material->SetRoughness(materialData.roughness);
|
||||
material->SetRoughness(absolutePath + "/../" + materialData.roughness);
|
||||
}
|
||||
|
||||
std::string materialPath;
|
||||
if(!materialData.albedo.empty())
|
||||
{
|
||||
materialPath = file->GetRelativePath() + "." + materialData.albedo + ".material";
|
||||
}
|
||||
ResourceManager::RegisterResource(material);
|
||||
ResourceManager::Manifest.RegisterResource(material->ID, materialPath);
|
||||
|
||||
std::string materialJson = material->Serialize().dump(4);
|
||||
FileSystem::BeginWriteFile(materialPath);
|
||||
FileSystem::WriteLine(materialJson);
|
||||
FileSystem::EndWriteFile();
|
||||
|
||||
mesh->MaterialResource = RID(material->ID);
|
||||
model->AddMesh(std::move(mesh));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
namespace Nuake
|
||||
{
|
||||
class Resource;
|
||||
|
||||
class RID
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -288,6 +288,9 @@ project "NuakeRuntime"
|
||||
"%{prj.name}/../Nuake/dependencies/freetype/include",
|
||||
"%{prj.name}/../Nuake/dependencies/tracy/public/tracy",
|
||||
"%{prj.name}/../Nuake/dependencies/entt/src",
|
||||
"%{prj.name}/../Nuake/src/Vendors/vulkan",
|
||||
"%{prj.name}/../Nuake/src/Vendors/volk",
|
||||
"%{prj.name}/../Nuake/dependencies/vma/include"
|
||||
}
|
||||
|
||||
libdirs
|
||||
@@ -341,9 +344,11 @@ project "NuakeRuntime"
|
||||
|
||||
externalincludedirs { "%{prj.name}/../Nuake/dependencies/Coral/Coral.Native/Include/" }
|
||||
|
||||
--[[
|
||||
postbuildcommands {
|
||||
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/Coral.Managed/Coral.Managed.runtimeconfig.json" "%{wks.location}/%{prj.name}"'
|
||||
}
|
||||
]]--
|
||||
|
||||
filter { "system:windows", "action:vs*" }
|
||||
flags
|
||||
|
||||
@@ -24,11 +24,17 @@ load_paths = {
|
||||
{ {"."}, .recursive = false, .relative = true }, .os = "win"
|
||||
},
|
||||
{
|
||||
{ {"Nuake"}, .recursive = false, .relative = true }, .os = "win"
|
||||
{ {"Nuake/src"}, .recursive = true, .relative = true }, .os = "win"
|
||||
},
|
||||
{
|
||||
{ {"Nuake/src"}, .recursive = true, .relative = true }, .os = "win"
|
||||
}
|
||||
{ {"Editor/src"}, .recursive = true, .relative = true }, .os = "win"
|
||||
},
|
||||
{
|
||||
{ {"NuakeNet/src"}, .recursive = true, .relative = true }, .os = "win"
|
||||
},
|
||||
{
|
||||
{ {"Runtime"}, .recursive = true, .relative = true }, .os = "win"
|
||||
}
|
||||
};
|
||||
|
||||
command_list = {
|
||||
|
||||
Reference in New Issue
Block a user