Merge pull request #73265 from clayjohn/tangent-oct

Bias octahedral tangent y axis to avoid errors around 0
This commit is contained in:
Rémi Verschelde 2023-02-14 11:05:52 +01:00
commit 570b04dec4
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -108,7 +108,9 @@ Vector3 Vector3::octahedron_decode(const Vector2 &p_oct) {
}
Vector2 Vector3::octahedron_tangent_encode(const float sign) const {
const float bias = 1.0f / 32767.0f;
Vector2 res = this->octahedron_encode();
res.y = MAX(res.y, bias);
res.y = res.y * 0.5f + 0.5f;
res.y = sign >= 0.0f ? res.y : 1 - res.y;
return res;