Compare commits

..

No commits in common. "7e9596d77fd8418ea49fbf1fdd254e5437822880" and "ff7eb827fef2df68d8c9ff6a5f1e71dc3543dc4c" have entirely different histories.

2 changed files with 25 additions and 42 deletions

View file

@ -228,43 +228,39 @@ namespace psemek::gfx
target.name = material["name"].GetString(); target.name = material["name"].GetString();
target.two_sided = false;
if (material.HasMember("doubleSided")) if (material.HasMember("doubleSided"))
target.two_sided = material["doubleSided"].GetBool(); target.two_sided = material["doubleSided"].GetBool();
else
target.two_sided = false;
// Material can omit pbrMetallicRoughness entry if auto const & pbr = material["pbrMetallicRoughness"];
// all the values are defaulted
if (material.HasMember("pbrMetallicRoughness")) if (pbr.HasMember("baseColorFactor"))
{ {
auto const & pbr = material["pbrMetallicRoughness"]; auto const & color = pbr["baseColorFactor"].GetArray();
gfx::color_4f & target_color = target.albedo.emplace();
for (std::size_t i = 0; i < 4; ++i)
target_color[i] = color[i].GetFloat();
}
if (pbr.HasMember("baseColorFactor")) if (pbr.HasMember("baseColorTexture"))
{ {
auto const & color = pbr["baseColorFactor"].GetArray(); target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64();
gfx::color_4f & target_color = target.albedo.emplace(); }
for (std::size_t i = 0; i < 4; ++i)
target_color[i] = color[i].GetFloat();
}
if (pbr.HasMember("baseColorTexture")) if (pbr.HasMember("metallicFactor"))
{ {
target.texture = document["textures"].GetArray()[pbr["baseColorTexture"]["index"].GetUint64()]["source"].GetInt64(); target.metallic = pbr["metallicFactor"].GetFloat();
} }
if (pbr.HasMember("metallicFactor")) if (pbr.HasMember("roughnessFactor"))
{ {
target.metallic = pbr["metallicFactor"].GetFloat(); target.roughness = pbr["roughnessFactor"].GetFloat();
} }
if (pbr.HasMember("roughnessFactor")) if (pbr.HasMember("metallicRoughnessTexture"))
{ {
target.roughness = pbr["roughnessFactor"].GetFloat(); target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
}
if (pbr.HasMember("metallicRoughnessTexture"))
{
target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
}
} }
if (material.HasMember("emissiveFactor")) if (material.HasMember("emissiveFactor"))

View file

@ -235,17 +235,4 @@ namespace psemek::math
return T{1} / T{2} - std::sin(std::asin(T{1} - T{2} * x) / T{3}); return T{1} / T{2} - std::sin(std::asin(T{1} - T{2} * x) / T{3});
} }
// Stateless piecewise-quadratic spline acceleration
// based on current velocity, current distance to target,
// and max acceleration
template <typename T>
T quadratic_spline_acceleration(T velocity, T distance, T max_acceleration)
{
T max_velocity = std::sqrt(2.f * std::abs(distance) * max_acceleration);
return max_acceleration
* (distance < 0.f ? -1.f : 1.f)
* ((std::abs(velocity) < max_velocity || (distance > 0.f) != (velocity > 0.f))? 1.f : -1.f)
;
}
} }