Last active
October 14, 2020 07:35
-
-
Save metal3d/fd4b0c7a9fc58eb24d1407c1fea601e0 to your computer and use it in GitHub Desktop.
Align Sky textyure with the sun lamp in Blender
This file contains hidden or 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
import bpy | |
import mathutils | |
# Author: Patrice Ferlet <[email protected]> | |
# License: GPL | |
# Works with Blender 2.80-2.90 | |
# To use this script: | |
# - paste this script in a "text editor" *inside* blender | |
# - name it "sun_set.py" | |
# - select a sun lamp (or any directional lamp) | |
# - press ALT+p with you mouse over the script | |
# The sky texture is now aligned to the sun lamp | |
# selected lamp | |
sun_lamp = bpy.context.selected_objects[0] | |
# get rotation euler | |
sun_rot = mathutils.Euler(sun_lamp.rotation_euler, sun_lamp.rotation_mode) | |
vec_rot = mathutils.Vector((0.0, 0.0, 1.0)) | |
vec_rot.rotate(sun_rot) | |
# apply to world sky texture | |
bpy.data.worlds['World'].node_tree.nodes['Sky Texture'].sun_direction = vec_rot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment