Connect light RGB values to shader RGB values - Eevee

Hey everyone.

Not sure if this is the right place to ask this, since it’s a bit of an odd question that could fit in a few places.

I’m trying to connect the RGB values of a light to the RGB values of a shader. My initial idea was to somehow control them with drivers, however I haven’t found any solid information on how to go about this. From a glance it seems like a simple solution but I haven’t a clue how to go about it, or if it’s even possible through a driver setup.

I’m not very familiar with the ins and outs of Eevee’s shading system so if it’s actually trickier than it sound then I would appreciate any links or resources that could share a bit more information on the subject. I’m just genuinely not sure what to search for to go about this problem.

The end goal is to be able to adjust just the light colour and have it influence one of the colour values of a ramp shader that’s mixed with an emission. I would show my node setup but I’m very inexperienced with this kind of thing, so most of it was figuring out how different nodes behaved with each other.


So, I think I’ve achieved the minimum of what you are trying to do: match the RGB value of a material with that of a lamp RGB value. Here’s how I did it:

Preface: I’m not sure this is the best way to do this, so any other clarification would be appreciated. Also, I’m using Blender 2.80 beta, so older versions may behave differently.

With the default scene (default cube, camera, point light), I right selected the light and gave it a color value other than its default color (with different R, G, and B values) so I could tell if my drivers were working for the individual channels - specifically, (1.0, .5, .25).

I then selected my cube and went to the Shader Editor. By default the Principled BSDF node connects to the Material Output node’s Surface input. I added an RGB node by pressing Shift + A, hovering over Input, and clicking RGB. On the RGB node, there is a color preview at the bottom that you can click to display the RGBA selection sliders. Right click on the preview without opening it and select Add Driver. You’ll get a “Show in Drivers Editor” popup - ignore it. Now, click the color preview and the RGBA selection sliders popup will show. You’ll see that the inputs have been colored purple. The process is basically the same for each color component, so I’ll only explain it fully once.

First, you want to select your source for your driver expression. Do this by selecting your lamp - in the default scene, the object is called “Light”. Go to the light object panel, hover over the light color preview, right-click and select “Copy Data Path”. Select your object again and your Shader Editor will show its node tree again. Click on the color preview of the RGB node to bring up the selection sliders. Right-click on the R: component slider and choose Edit Driver. Now follow the below steps referencing the attached screenshot:

  1. Click the Driver Variable Type dropdown and change it from Transform Channel to Single Property.
  2. Change the name of the variable from var to Red. This variable name is not directly connected to your lamp’s R value. It could literally be named Elephant, but when dealing with programming languages you want to use variable names that are meaningful, and var does not mean anything to you at this point.
  3. Click the ID block Type dropdown and select Light.
  4. Click the ID block Name list and select the name of your light (in this case, its name is Light).
  5. Click in the Path field, and paste the data path we copied before. It should now show as simply the word color.
  6. Blender stores the RGBA data for the color of a lamp in a collection. In programming, individual items in a collection can be referenced by using their index number - in Python, referencing the first item in a collection is done by starting at zero and looks like collection[0]. You want to reference the first item in the color collection (the red component value), so you will type [0] at the end of the color path that you just pasted. For subsequent drivers, green will be referenced by adding [1] at the end of the pasted data path and blue will be referenced by adding [2] at the end of the pasted data path.
  7. Finally, change your Expression to simply reference the name of the variable you created in step 2 - Red.

Repeat those steps for the green and blue component drivers, and your drivers are done. Finally, connect the color output of the RGB node into the base color input of the Principled BSDF node. Now any change in the color of the light will update the color of your object’s base color.


Please let me know if you need clarification or additional assistance. Happy blending!


First of all, your response was far and beyond what I expected. Thank you very much for a clear and detailed answer! I can say with 100% that this does exactly what I was hoping for, and it even works on ramp shaders! I did notice with the ramp the cube got got stuck on a colour a few times but after setting up an RGB node and swapping between them the problem seems to have disappeared.

This was immensely helpful and I’m glad the process didn’t require a complex setup. Funny backdoor work around but an interesting insight into how drivers work in Blender. I’m going to experiment with the setup you’ve provided to see if I can achieve any interesting results.

Thanks again!