3
$\begingroup$

I want to control a traffic light. As easy as possible.

So i have 3 objects with emitters and i would control the strength of the lights by 3 variables/custom attributes: Red, Yellow, Green - which basically just hold the strength value for the emitter color.

But if i understood it correctly i cannot get custom attributes from shader editor/nodes. Is that correct?

I could now use drivers to copy my control variables to my 3 objects in e.g. the viewport color and use them.

But...it there another way? If yes, I would like to hear that!

Thanks.

$\endgroup$
5
  • $\begingroup$ Hey I didn't understand if you wanted to get values out of the shader tree or into the shader tree ? The former is not possible afaik and the latter you can do with an Attribute node with either a custom property on the object or an attribute on the geometry using Geometry nodes $\endgroup$
    – Gorgious
    Oct 2 at 17:26
  • $\begingroup$ Sorry for not being clear enough. I want a value into the shader tree. I tried to access the custom attribute with ["custom attribute"] but it didn't work $\endgroup$
    – Chris
    Oct 2 at 17:32
  • $\begingroup$ You don't have to use the commas and brackets in this node, just the property name which is case sensitive, and dont forget to set the type to Object and not Geometry $\endgroup$
    – Gorgious
    Oct 2 at 17:47
  • $\begingroup$ @Gorgious: my problem is, that i want to take the custom property of another object (the traffic light controller) to change the emission strength for red (object1), yellow (object2) and green(object3). Is this possible too? So unfortunately it is not the same object where the shader node tree is used... $\endgroup$
    – Chris
    Oct 2 at 17:56
  • 1
    $\begingroup$ I didn't test it but I think you can drive the custom property of obj A with the custom property of obj B (the master driver) and then use it in your shader editor. Not as straightforward though $\endgroup$
    – Gorgious
    Oct 2 at 18:50
6
$\begingroup$

Overview

On the lamp object, I added a Custom Property I named Emission. I then created a material that uses an Attribute node set to Emission and plugged it into the Emission Strength input of a Principled BSDF through a Multiply node to adjust the strength.

I duplicated the material for Red, Green, and Yellow lights. I duplicated the lamp object 6 times and applied the appropriate material to each.

Each lamp object has its own copy of the Emission attribute, and these Custom Property attributes can have drivers attached so you can set up a controller using drivers.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.