1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Normalize the results of octahedral decompression

This commit is contained in:
clayjohn
2021-08-16 22:17:38 -07:00
parent 4032d26dd5
commit 8ac85e6a9e
3 changed files with 3 additions and 3 deletions

View File

@@ -115,7 +115,7 @@ vec3 oct_to_vec3(vec2 e) {
vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y)); vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
float t = max(-v.z, 0.0); float t = max(-v.z, 0.0);
v.xy += t * -sign(v.xy); v.xy += t * -sign(v.xy);
return v; return normalize(v);
} }
#endif #endif

View File

@@ -264,7 +264,7 @@ vec3 oct_to_vec3(vec2 e) {
vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y)); vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
float t = max(-v.z, 0.0); float t = max(-v.z, 0.0);
v.xy += t * -sign(v.xy); v.xy += t * -sign(v.xy);
return v; return normalize(v);
} }
#endif #endif

View File

@@ -376,7 +376,7 @@ Vector3 VisualServer::oct_to_norm(const Vector2 v) {
float t = MAX(-res.z, 0.0f); float t = MAX(-res.z, 0.0f);
res.x += t * -SGN(res.x); res.x += t * -SGN(res.x);
res.y += t * -SGN(res.y); res.y += t * -SGN(res.y);
return res; return res.normalized();
} }
// Convert Octohedron-mapped normalized tangent vector back to Cartesian // Convert Octohedron-mapped normalized tangent vector back to Cartesian