From 5a800e68f1699c278078ff96100b0c0ea9a1780e Mon Sep 17 00:00:00 2001 From: clayjohn Date: Mon, 13 Feb 2023 19:24:14 -0800 Subject: Bias octahedral tangent y axis to avoid errors around 0 --- core/math/vector3.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core') 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; -- cgit v1.2.3