Can I use a geometry node to select or modify the material of a single object?

I have created stage lighting setup, and a lighting dimmer board with 126 buttons for selecting the channel of specific spotlights (7 buttons each for 18 lights).

I would like each button to glow when it is pushed down (i.e. moved along its z-axis). At first I was thinking of using a driver to change the emission of the material, but that would mean making a separate material for each button!

Is there a way to use geometry nodes to either change the emission of a single object according to its z coordinate?

Or perhaps selecting a different material slot may be more straightforward. Could I create a different material for button up and button down, and select the material slot according to button location?

I am new to geometry nodes so have very little idea of the capabilities or use. Any ideas or suggestions about where to educate myself would be most appreciated.

Can I use a geometry node to select or modify the material of a single object?

Yes, of course this also works with Geometry Nodes.

In this example I have a button consisting of two elements:

• The Button
• The LED

I combine both objects using Geometry Nodes.

Additionally I created a Group Input, which can be controlled from outside by Driver or similar.

This float value transforms the rotation of the button on the one hand, and the light of the LED on the other hand.

For this I use the node Compare with the setting Greater Than. As soon as the button press reaches a certain value, I store a boolean value with Store Named Attribute into the geometry of the LED.

This value can then be queried in the shader and used to control the Emission.

• +1 Nice solution as well. I didn't go for Geometry Nodes (which of course can do such things) because the premise of the question was that he thought of creating a material but thought he had to make a separate material for each object... so I showed a way to do it with a single material for all objects. Commented Jul 13, 2022 at 11:46
• @GordonBrinkmann Thanks! Since Geometry Nodes store an additional attribute in the geometry here, it is of course also possible to use only one material. The shader ultimately decides here which part of the geometry gets which appearance. Commented Jul 13, 2022 at 11:49
• Yes, sure there's only one material needed ;) As I said, I know GN can do a lot of things, it was just that if somebody isn't so experienced in GN as the OP himself stated, it wouldn't matter since you can do it completely without GN. Commented Jul 13, 2022 at 11:54
• @GordonBrinkmann You hit the nail on the head: You can actually do almost everything without Geometry Nodes. But with Geometry Nodes it's much more fun in my opinion :D Commented Jul 13, 2022 at 12:01
• very nice button! ;) Commented Jul 13, 2022 at 12:15

//EDIT: If you want to be indenpendent from global positions/rotations, you will find a solution with shape key and driver below.

When the Z coordinate is the only thing that matters for the decision, you can do this with a single material for all objects.

Go to the Shader Editor, take an Object Info node, plug the Location output into a Separate XYZ node. The Z value goes into a Math node set to Less Than with the desired threshold value. The result goes into the Emission Strength of a Principled BSDF or whatever you use to make the button glow. (I multiplied the result with 10 to make it brighter).

Now for the solution that's indenpendent of all global positions or rotations.

1. Join the button (not pushed down) with the housing by pressing Ctrl+J. Go to the Object Data Properties > Shape Keys and press the Plus button twice to create the basis and a key.

1. Go into Edit Mode, select all faces that belong to the button and move them down into the "pushed" position. Now switch back to Object Mode.

1. Go to the shape keys again, select the key, right-click on the Value field and choose Copy as New Driver.

1. A little further down you'll find Custom Properties, click New and on the created prop value you can right_click and choose Paste Driver. You can also rename it to your liking by clicking the cog symbol to the right. You'll need the name in the material later, I called it "push".

1. In the material, add an Attribute node. Select the Type: "Object" and enter the Name you have given to the property, in my case "push". Connect the Fac output to a Math node set to Greater Than. If you now change the value of the shape key between 0 to 1 "pushing" the button, the value will be compared in the Greater Than node to the threshold value and switch on the emission when exceeding it. By the way: yes, you can paste a driver directly into the Math node without the need for a custom property. But when I tried it, one shape key controlled all glow, no matter if the other buttons were pushed or not. Therefore the custom property as a workaround.

Since the shape key and the material using the driver are completely independent from location and rotation of the object, the effect works always no matter where and how you place it.

• Thanks @Gordon Brinkmann - that's a great start. You're right about the global/local issue. In fact my board is angled at 15 degrees so I'd need to local coordinate. I'll look into it. Commented Jul 13, 2022 at 8:29
• @Thailandian I'm working on a solution for that and edit this as another option in my answer ;) Commented Jul 13, 2022 at 8:31
• @Thailandian I'll leave the "global" solution as well, but I think my edit should do what you need. Commented Jul 13, 2022 at 9:41
• Brinkman - Thanks, I had just come up with a similar solution, but instead of using a shape key, I just copied the RNA attribute of the object's location into the node and used the Vector output. I'll post my answer below as an alternative. Commented Jul 13, 2022 at 10:46
• @Thailandian I have no idea what the RNA attribute is :D Commented Jul 13, 2022 at 10:57

Here is another solution, similar to Gordon Brinkmann's original idea.

Similarly to Gordon's second solution, I replaced the Object Info node with an Attribute node. This can output any RNA attribute value of an object (amongst other things).

To get the RNA attribute, right-click on that field - in my case the z coordinate in the Transform fields, and select "Copy Data Path" from the context menue.

Then I used Vector output of the Attribute Node to control the Emission Strength.

The emission is now dependent on the local z coordinate, and the parent's location rotation or scale has no impact.

• Ah, you can put the data path in there as well. Didn't know this is called RNA attribute. So you found your own solution ;) The only advantage my setup has: you can model the button as one piece and don't have to duplicate two or more objects. Commented Jul 13, 2022 at 11:36
• @PPL I didn't copy or paste anything since this is not my answer. Commented Dec 31, 2022 at 0:09
• Sorry Gordon Brinkman I meant to ask the author of the solution. @Thailandian are you saying the 'copied' datapath was pasted into the 'Name' field of the Attribute node? I see you copied it but wasn't clear where you pasted it into
– PPL
Commented Dec 31, 2022 at 23:19
• @PPL Sorry for the slow reply - ironically, my computer has been down for the past 2 weeks! To answer your question, I now realise it's not necessary to paste the datapath into the Attribute Name field (although it does work). Easier is simply to write "location" into the box. Commented Jan 16, 2023 at 9:18