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

Scalable Vector Graphics support (similar to #72) #134

Open mattrdowney opened 5 years ago

mattrdowney commented 5 years ago

There are a couple of new possibilities using Unity's scalable vector graphics support.

Generally, there are two possibilities:

1) render to a single plane which gets folded like flower petals into a sphere. 2) render as a cube which gets sphere-ified.

I need to grab a callback when the vertices are being generated to reconstruct a mesh that is a sphere. If I can get option 1 working, that's great because the seam/discontinuity is a single point. If option 2 is necessary (or even worse, necessary and I cannot sphere-ify it), then there will be more pain to get things working as I want them (especially with efficiency concerns).

Builder patterns work better using Unity's new interface for constructing vector graphics at runtime, so I might just get rid of the concept of .pvg files #72 altogether (because they are redundant / overly complicated).

mattrdowney commented 5 years ago

I think there is a real (and statistically inevitable) chance that a straight vector graphics line is generated, and when the mesh is being morphed it will create too little detail (and possibly cause the sphere to look e.g. like a hemisphere because of the missing detail). Equator lines seem like a possible reason that would happen.

mattrdowney commented 5 years ago

Coding this generically, so that multiple formats can be used/tested might be a good idea (or over-engineering?)

mattrdowney commented 5 years ago

In order to avoid detail issues, the best solution is to recursively subdivide triangles in 4 when their max edge length exceeds some threshold.

mattrdowney commented 5 years ago

Notably, this distance is before wrapping it into a sphere.

mattrdowney commented 5 years ago

Actually, the distance is harder to compute (the circle texture's distances are only accurate towards the center). You probably want to compute distance afterwards (with a notion of direction to figure out if the arc went around the sphere).

mattrdowney commented 5 years ago

Also, there are three good algorithms (cube, polar coordinates, octahedron) - like I originally thought.

Octahedron probably has the best precision for a single vector graphic (while maintaining ease of implementation).

The issue with a polar coordinates / world lotus is that the south pole / distant fringes get a (infinitely) disproportionate amount of detail.