Skip to content

Instantly share code, notes, and snippets.

@steveherrin
Last active August 10, 2020 06:08
Show Gist options
  • Save steveherrin/a66fa5c998cdc28114e51cef0587faae to your computer and use it in GitHub Desktop.
Save steveherrin/a66fa5c998cdc28114e51cef0587faae to your computer and use it in GitHub Desktop.
useful Blender snippets
def stereographic_project(obj):
"""
Given a 2D xy plane, project it onto a 1 m sphere centered at the origin
A point source of light placed at the top of this sphere (z = 1 m)
will then cast a shadow that looks the same as the original plane
"""
for vert in obj.data.vertices:
x = vert.co.x
y = vert.co.y
denom = (x*x + y*y + 1.0)
vert.co.x = 2.0 * x / denom
vert.co.y = 2.0 * y / denom
vert.co.z = (x*x + y*y - 1.0) / denom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment