Skip to content

Commit

Permalink
Merge pull request #73265 from clayjohn/tangent-oct
Browse files Browse the repository at this point in the history
Bias octahedral tangent y axis to avoid errors around 0
  • Loading branch information
akien-mga committed Feb 14, 2023
2 parents 1a206d0 + 5a800e6 commit 570b04d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/math/vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 570b04d

Please sign in to comment.