Synchronize Sun light to HDRI in Blender

Activate Sun Position add-on

Sun Position add-on comes bundled with Blender 2.91. To activate the add-on go to Edit>Preferences>Add-ons and search for “Sun Position”. Enable an add-on. In its preferences, you can enable additional information labels if needed. Once activated, the add-on will be visible in World Properties of Blender.

Enable Sun Position add-on – no download needed, it comes with Blender app

Create a test scene and HDRI lighting

  • Leave default cube, add Plane object under the cube, and scale 10 times.
  • Go to Object Properties > Visibility enable Shadow Catcher.
  • In shader editor add some HDRI environment map. If you have Node Wrangler enabled, you can select Background node and press CTRL + T to create all nodes.
  • Load 2K sample HDRI map from here to Environment Texture node. Switch to Cycles rendering engine and turn on Viewport Preveiw Mode (shortcut Z + 8)
  • Lower Background’s Strength value if it’s too bright. 
Simple test scene with default cube

Attaching Sun light to HDRI

  1. Select default Point light and switch it to Sun type. If the scene preview is too bright, you’d need to lower its Strength to a reasonable value (between 2 and 5).
  2. Switch to the World Properties and the Sun Position panel. 
  3. Select Usage mode: Sun + HDR texture
  4. For the Sun object select Light
  5. Click on Sync Sun to Texture, make sure that you are on 3D Viewport is in display Preview Mode (shortcut Z + 8), otherwise, the plugin won’t work properly. 
  6. You should now be able to see your hdri map and two crossing lines. Use the mouse scroll button to get closer to zoom, and if hdri is too bright use CTRL + mouse scroll wheel to make it darker in preview. Click where sun should be, even if it’s not visible on hdri.
  7. Now when your Sun light is attached to HDRI map, you can rotate the whole of your lighting setup using Sun Position > Rotation input field. Tweak a Distance and Rotation to your needs. Select Sun lamp and set its color to something more yellow so it matches the natural environment. if the shadow is too harsh, you can fix it by increasing Sun Light’s Angle number.
Sun Position add-on in action

Rendering and conclusion

When you toggle Light off and on in preview, you will notice how blue cast coming from hdri has gone, and cube casts a softer shadow when light is activated and rendered directly on plane. In such a scenario, additional Sun light can help you to improve hdri color balance (reducing the blue tinge coming from the hdri map).

Test cube rendered on Plane (no shadow catcher enabled)

When rendering directly on shadow catcher, the cube has almost no visible shadows. Introducing additional light improved shadows significantly. HDRI blue tinge has been smoothly balanced with yellow Sun light.

Test render on Plane with Shadow Catcher enabled on