Parse metallic & roughness pbr parameters from glTF materials
This commit is contained in:
parent
564a0001a2
commit
64672d3f1f
2 changed files with 12 additions and 0 deletions
|
|
@ -60,6 +60,8 @@ namespace psemek::gfx
|
||||||
std::string name;
|
std::string name;
|
||||||
bool two_sided;
|
bool two_sided;
|
||||||
std::optional<color_4f> albedo;
|
std::optional<color_4f> albedo;
|
||||||
|
std::optional<float> metallic;
|
||||||
|
std::optional<float> roughness;
|
||||||
std::optional<std::size_t> texture;
|
std::optional<std::size_t> texture;
|
||||||
std::optional<color_3f> emission;
|
std::optional<color_3f> emission;
|
||||||
std::optional<std::size_t> emission_texture;
|
std::optional<std::size_t> emission_texture;
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,16 @@ namespace psemek::gfx
|
||||||
target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64();
|
target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pbr.HasMember("metallicFactor"))
|
||||||
|
{
|
||||||
|
target.metallic = pbr["metallicFactor"].GetFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pbr.HasMember("roughnessFactor"))
|
||||||
|
{
|
||||||
|
target.roughness = pbr["roughnessFactor"].GetFloat();
|
||||||
|
}
|
||||||
|
|
||||||
if (pbr.HasMember("metallicRoughnessTexture"))
|
if (pbr.HasMember("metallicRoughnessTexture"))
|
||||||
{
|
{
|
||||||
target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
|
target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue