mattrdowney / planetaria

A Unity framework for Euclidean 2-sphere games (e.g. 2D virtual reality games) [quasi-MIT license]
Other
10 stars 2 forks source link

OctahedralUVCoordinates and NormalizedOctahedronCoordinates may have "wrong" encoding. #80

Closed mattrdowney closed 6 years ago

mattrdowney commented 6 years ago

This is all conjecture:

Originally, I noticed that the tessellated octahedron mesh worked for 1) the octahedron itself and 2) highly tessellated meshes very close to a sphere. In-between values seemed "off", though.

If I'm right on this i.e. the morphology of the sphere to octahedron is "wrong" (there's technically infinite options), then octahedron tessellation won't be required (just scaling up to ~2).

The goal is to try using this morphology/mapping: https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/

This will provide a better distribution of values and ensure that sphere and octahedron values are both functionally identical.

mattrdowney commented 6 years ago

Blind commit on e150915ebe75e86b410271be4bf1a335884738fe

mattrdowney commented 6 years ago

Not a bug (specifically because game engines are locking into triangle barycentric coordinates by default for UVs i.e. linear interpolation (overriding would be possible but not worth it)).

Personally, I think that using an icosahedron is a better idea now, with the knowledge that space conversions is relatively simple. Tesselation is a different beast, but a nice side effect is how the UV triangles would end up being equilateral (since there's no convenient mapping for 20 triangles).

I will close this comment with "wontfix", but I changed the code and it might be broken. The code does the same thing (similar to my old code), but is more efficient than the version that uses a "data-driven" approach.

mattrdowney commented 6 years ago

While this isn't actually being implemented; there was a change to how UVs are calculated in 54ec8ca75fba5615d843b1fcbf79644c7c7cc49a