MightyBOBcnc / nixis

A python program for procedurally generating planet-scale maps for Earth-like, spherical worlds.
MIT License
8 stars 0 forks source link

Dev #13

Closed NorthernScott closed 9 months ago

NorthernScott commented 1 year ago

Hey Bob, I've committed my changes here just so you can see where I'm at. I'm basically rebuilding a simplistic version of your code as an exercise in understanding all of the pieces. I've got almost everything in in lathe.py and I've started the beginning of a CLI in cli.py.

MightyBOBcnc commented 1 year ago

Looking good so far but I have a concern with PyVista's icosphere doing its subdivisions recursively. This dramatically limits our ability to control the density of the mesh points, especially at higher recursion levels. Meshzoo, on the other hand performs its subdivision by changing the Frequency (class 1) which basically means for each of the icosahedron's original 12 edit: 30 edges, split that edge into N edges, rather than divide the edge by 2, and then each child by 2 again, and again etc.

Top row, recursive subdivision, bottom row frequency subdivision: image (NOTE: a recursion level of 9 is equal to a frequency of 512)

At low levels this isn't a problem but the reason this concerns me is that I'm not certain that we can extract 1km/px maps from only ~2.6 million points. At Earth's radius, an icosphere of that point density has edge lengths of about 11 to 16 kilometers (mean ~15km) between points so there is no smaller detail to extract. In a literal sense, yes we can extract a 40k*20k image from 2.6 mil points but making the image bigger wouldn't cause more detail to be present.

Therefore we'd need more than 2 million points, but when using recursive subdivision we don't have the option to go to, say, 3 or 5 million as an example. The next level of recursion is 10,485,762 points and one level after that is nearly 42 million points, and it only gets worse from there. With frequency subdivision we can dial in a number of points that more closely matches the desired level of detail without way way overshooting the needed number of points.

Now, with that being said I haven't precisely calculated how many points are required, but some rough math suggests that it takes 250 million points to get a mean distance between points of about 1.5km which is... substantial... ~62 million points would average about 3km between points. Now, we may not need to go quite that high with the icosphere because 1) the mapping of triangle points to an image (which is a latitude/longitude grid) likely doesn't need to be 1:1 density, and 2) the current image export function takes a distance-weighted average of 3 nearby vertices for each pixel of the image, so this makes a blending or anti-aliasing-like effect that 'fills in the gaps' so to speak. (There may also be a better technique than this.)

But anyway, the takeaway is that we might need more points and recursive subdivision makes that troublesome the higher we go.

NorthernScott commented 1 year ago

That's a sound thought. That said, I'm still inclined to use PyVista because a) no licence considerations, b) fewer dependencies, and c) as I am continuing to work it with, I am liking its functionality more and more, and would love to just use it from start to finish.

Based on my searches, Earth has a total surface area of approximately 519m km2, which is far less than a perfect sphere of the same radius because lumpy potato. A 2D grid of 36,000 x 18,000 pixels gives us 648m px.

I think the real issue we need to figure out is what resolution we need / want to aim for.