4
$\begingroup$

Setup

I've generated a 'planet' using the ANT landscapes add-on. The exact parameters don't really matter, but suffice to say that it's visually a UV sphere mesh with vertices pushed from the center to varying heights. There is a copy of the object that has had all the 'ocean' faces removed.


Intended goal

Project the globe onto some sort of map (the cartography kind). I'd love to have one of the (more) standard map projections, like a Winkel tripel projection or one of the really cool looking ones, like a Dymaxion or a Waterman butterfly, but I'm really just trying to get it to work.


Current approach

After fooling around with modifiers until my eyes hurt, I finally decided to just bash out the following spaghetti code:

import bpy
from math import *
def map_sphere(bpy_obj):
    vert_cnt = len(bpy_obj.data.vertices)
    coord = [0]*vert_cnt*3
    bpy_obj.data.vertices.foreach_get('co',coord)
    for i in range(vert_cnt):
        x,y,z = coord[3*i:3*i+3]
        p = sqrt(x**2 + y**2 + z**2)
        phi = acos(z/p)
        theta = asin(y/(p*sin(phi)))
        coord[3*i:3*i+3] = [phi,theta,p]
    bpy_obj.data.vertices.foreach_set('co',coord)

Basically, flop the vertices into spherical coordinates and map the spherical coordinates back into the object according to ($\phi$->x, $\theta$->y, $\rho$->z). It's pretty simple, but I'm running into a few key issues:

  • Huge amount of distortion around the poles
  • Weird scaling factors in the X and the Y directions
  • Points on the poles are unmappable. (solved by deleting them.)

Question

  1. Is this the best way of doing this? I feel like it's far too roundabout and there's probably some obvious solution.

  2. If this is the best way of doing this, then how can I reduce the distortion around the poles and/or are there other easily programmable mapping schemes besides equirectangular?


Additional troubleshooting done since posting

I took a simple UV sphere and applied the program to it. The end result was a mesh with two layers literally in the same place. Perhaps I should simply cut my mesh in half and operate on each half separately?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

well I would say create your UVs like you want them to look, then bake the texture using an equilateral environnement texture plugged in an emit shader with object as coordinate (assuming object pivot point is at the center)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .