Last active
August 10, 2020 06:08
-
-
Save steveherrin/a66fa5c998cdc28114e51cef0587faae to your computer and use it in GitHub Desktop.
useful Blender snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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