I'm working on the 3D visualization of planets in the solar system. As I am going to apply texture, I have manually computed the texture coordinates (texcoords
), however, I get zig-zag artefacts appeearing in the image.
I believe that my computation might be wrong. I have attached the texcoords
computation below:
# Compute Texture Coordinates
def get_texcoords(vertices):
texcoords = []
for v in vertices:
#thresholding
for i in range(3):
if np.abs(v[i]) > 1e-6:
v[i] = v[i]
elif np.abs(v[i]) < 1e-6:
v[i] = 0.0
# Compute position in uv-space
radius = np.sqrt(v[0]**2 + v[1]**2 + v[2]**2)
latitude = np.arcsin(v[2]/radius)
longitude = np.arctan2(v[1],v[0])
# Convert to texture coordinates
u = round(0.5 + longitude/(2*np.pi),5)
v = round(0.5 + latitude/np.pi,5)
texcoords.append([u,v])
return np.array(texcoords)
Is there any way to remove the artefacts? Or is there a smarter way to obtain texture coordinates in vispy
?