Parse emission texture & KHR_materials_emissive_strength from glTF
This commit is contained in:
parent
fcd86fb359
commit
21e35a988a
2 changed files with 18 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ namespace psemek::gfx
|
|||
std::optional<color_4f> albedo;
|
||||
std::optional<std::size_t> texture;
|
||||
std::optional<color_3f> emission;
|
||||
std::optional<std::size_t> emission_texture;
|
||||
std::optional<std::size_t> material_texture;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ namespace psemek::gfx
|
|||
static std::unordered_set<std::string> supported_extensions =
|
||||
{
|
||||
"KHR_lights_punctual",
|
||||
"KHR_materials_emissive_strength"
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -207,6 +208,22 @@ namespace psemek::gfx
|
|||
for (std::size_t i = 0; i < 3; ++i)
|
||||
target_emission[i] = emission[i].GetFloat();
|
||||
}
|
||||
|
||||
if (material.HasMember("emissiveTexture"))
|
||||
{
|
||||
target.emission_texture = document["textures"].GetArray()[material["emissiveTexture"]["index"].GetUint64()]["source"].GetInt64();
|
||||
}
|
||||
|
||||
if (material.HasMember("extensions"))
|
||||
{
|
||||
auto const & extensions = material["extensions"];
|
||||
if (extensions.HasMember("KHR_materials_emissive_strength"))
|
||||
{
|
||||
if (!target.emission)
|
||||
target.emission = {1.f, 1.f, 1.f};
|
||||
*target.emission *= extensions["KHR_materials_emissive_strength"]["emissiveStrength"].GetFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (document.HasMember("images")) for (auto const & image : document["images"].GetArray())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue