Skip to content

Instantly share code, notes, and snippets.



Last active Oct 14, 2020
What would you like to do?
Align Sky textyure with the sun lamp in Blender
import bpy
import mathutils
# Author: Patrice Ferlet <>
# License: GPL
# Works with Blender 2.80-2.90
# To use this script:
# - paste this script in a "text editor" *inside* blender
# - name it ""
# - 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))
# apply to world sky texture['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