Compare commits
2 commits
ff7eb827fe
...
7e9596d77f
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e9596d77f | |||
| 156a58a59a |
2 changed files with 42 additions and 25 deletions
|
|
@ -228,11 +228,14 @@ 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
|
||||||
|
// all the values are defaulted
|
||||||
|
if (material.HasMember("pbrMetallicRoughness"))
|
||||||
|
{
|
||||||
auto const & pbr = material["pbrMetallicRoughness"];
|
auto const & pbr = material["pbrMetallicRoughness"];
|
||||||
|
|
||||||
if (pbr.HasMember("baseColorFactor"))
|
if (pbr.HasMember("baseColorFactor"))
|
||||||
|
|
@ -262,6 +265,7 @@ namespace psemek::gfx
|
||||||
{
|
{
|
||||||
target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
|
target.material_texture = document["textures"].GetArray()[pbr["metallicRoughnessTexture"]["index"].GetUint64()]["source"].GetInt64();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (material.HasMember("emissiveFactor"))
|
if (material.HasMember("emissiveFactor"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -235,4 +235,17 @@ 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)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue