Support material names & emission in gltf parser
This commit is contained in:
parent
5ce8647b3d
commit
ce1809e50d
2 changed files with 12 additions and 0 deletions
|
|
@ -34,8 +34,10 @@ namespace psemek::gfx
|
|||
|
||||
struct material
|
||||
{
|
||||
std::string name;
|
||||
std::optional<color_4f> albedo;
|
||||
std::optional<std::size_t> texture;
|
||||
std::optional<color_3f> emission;
|
||||
};
|
||||
|
||||
struct texture
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ namespace psemek::gfx
|
|||
{
|
||||
auto & target = result.materials.emplace_back();
|
||||
|
||||
target.name = material["name"].GetString();
|
||||
|
||||
auto const & pbr = material["pbrMetallicRoughness"];
|
||||
|
||||
if (pbr.HasMember("baseColorFactor"))
|
||||
|
|
@ -116,6 +118,14 @@ namespace psemek::gfx
|
|||
{
|
||||
target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64();
|
||||
}
|
||||
|
||||
if (material.HasMember("emissiveFactor"))
|
||||
{
|
||||
auto const & emission = material["emissiveFactor"].GetArray();
|
||||
gfx::color_3f & target_emission = target.emission.emplace();
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
target_emission[i] = emission[i].GetFloat();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const & image : document["images"].GetArray())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue