From d68242d59d52f00571b45da2339f94df71414a8a Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 18 Mar 2023 17:36:52 +0300 Subject: [PATCH] Support material texture in gltf parser --- libs/gfx/include/psemek/gfx/gltf_parser.hpp | 1 + libs/gfx/source/gltf_parser.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/libs/gfx/include/psemek/gfx/gltf_parser.hpp b/libs/gfx/include/psemek/gfx/gltf_parser.hpp index 976c871a..9c5b8008 100644 --- a/libs/gfx/include/psemek/gfx/gltf_parser.hpp +++ b/libs/gfx/include/psemek/gfx/gltf_parser.hpp @@ -48,6 +48,7 @@ namespace psemek::gfx std::optional albedo; std::optional texture; std::optional emission; + std::optional material_texture; }; struct texture diff --git a/libs/gfx/source/gltf_parser.cpp b/libs/gfx/source/gltf_parser.cpp index 73b40b52..b8c61797 100644 --- a/libs/gfx/source/gltf_parser.cpp +++ b/libs/gfx/source/gltf_parser.cpp @@ -170,6 +170,11 @@ namespace psemek::gfx target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64(); } + if (pbr.HasMember("metallicRoughnessTexture")) + { + target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64(); + } + if (material.HasMember("emissiveFactor")) { auto const & emission = material["emissiveFactor"].GetArray();