summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-02-14 11:05:52 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-02-14 11:05:52 +0100
commit570b04dec4adfb1f55a168cfae99768308bab506 (patch)
tree99038c3c105fc6d4e4fa89880782ae6c240e6ad1 /core
parent1a206d0e22357587b198fc8fcdc99d95c82567da (diff)
parent5a800e68f1699c278078ff96100b0c0ea9a1780e (diff)
Merge pull request #73265 from clayjohn/tangent-oct
Bias octahedral tangent y axis to avoid errors around 0
Diffstat (limited to 'core')
-rw-r--r--core/math/vector3.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index d732f1e8b2..ae009fc4ef 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -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;