Dynamic Locator Scale for lights (update)

Sorry, I forgot to add the “code” tag. Now the hyphens are correct!

Hi there,

If you ever experienced fatigue for constantly change the Locator Scale attribute at sunDirection (Physical Sun and Sky, directional light node), here is a simple solution.

What does this expression do:
It’s changing the Locator scale value depending on the distance between the camera (persp) and the sunDirection node.

sunShape node, Object Display section

  • Create an expression for Locator Scale attribute
    (right click, Create New Expression…)
  • Paste this code:

sunShape.locatorScale = 0.05 * sqrt( pow((persp.translateX - sunDirection.translateX),2) + pow((persp.translateY - sunDirection.translateY),2) + pow((persp.translateZ - sunDirection.translateZ),2) );

  • Click to Create button.
  • Change the multiplier for your needs.

You can easily create other expressions for other lights based on this (change the light name of course 🙂 ).

Cheers, D

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.