Updated “Longitude and Latitude” values are displayed in the panel (can be edited)
Select any object and click “Rotate object” to align it with a vector from the calculated point to origo
To add a new sun (rotated in alignment with the current sun position), click “Add new sun”
The new sun will be located in a new collection, “HDRI Sun Aligner”
Find more details and installation instructions on my GitHub repository.
Version 1.2 - fixes and improvements
“Add new sun” operator to add a new sun, rotated in alignment with the current sun position
Version 1.1 - fixes and improvements
No dependency on OpenCV, only Numpy which is already included with Python in Blender
I.e. no need to install any additional Python library
Improved usability with new panel in 3D Viewport
Update sun position (calculate brightest spot in HDRI)
Display of calculated Longitude and Latitude (can be changed by user)
Rotation of selected object according to coordinates
Preview is displayed in the Image Editor
Ideas for future updates:
Handle rotated HDRI’s (i.e. if the HDRI is rotated by a mapping node)
Change the static preview to something dynamic where you can click on a coordinate in the preview and automatically add a light source at that position (with correct rotation of course), including sampling of the color at that coordinate
Make it possible to change the position of the detected brightest point (dynamically by clicking in the HDRI preview)
This is a great idea. I’m currently using OpenCV and the “imshow” function for displaying the static preview window, but if this is changed to use e.g. the Image Editor instead, I believe it’s possible to get the coordinates and color sample in real time? The mapping from 2D coordiates to 3D rotation is already in place and can be reused (that was the most complicated thing to get right). Let me do some tests and see how it goes.
Nice, but it require openCV lib. So i cannot activate the plugin.
Modules Installed () from 'C:\\Users\\wx^c\\Downloads\\hdri-sun-aligner-master.z
ip' into 'C:\\Users\\wx^c\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\
Traceback (most recent call last):
utils.py", line 351, in enable
mod = __import__(module_name)
File "C:\Users\wx^c\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\ad
dons\hdri-sun-aligner-master\__init__.py", line 15, in <module>
ModuleNotFoundError: No module named 'cv2'
Edit : After install python-opencv with pip inside the bundler python, I can activate it.
It looks to work nice. Maybe you can add the way to move the blue circle in case of false detection ?
Thanks @warnotte for testing, I updated the initial post with a reference to the Readme where there are more details on the required OpenCV library and how to install it using “pip”.
I will for sure try to make the HDRI preview interactive, allowing for adjusting the position of the detected sun position as well as the possibility to dynamically add a light source at any position by clicking on the image (and sampling the color as suggested by @gestoryscht).
Nice!! You could easily achieve the same functionality with just numpy and matplotlib instead of the rather clunky opencv. Matplotlib also allows you to query mouse click positions. You could perhaps use local maxima to detect several light sources automatically.
Do you have the same problem that the “cv2” module cannot be imported when you activate the addon? If so, you need to open a Command Prompt (assuming you are on a Windows environment) and run the following commands (one by one). Note that you need to replace <path to blender> with the actual path where you have extracted the Blender ZIP file (from the daily builds), e.g. C:\Downloads\Blender\