Get light colour in material

Is it possible to get the combined light contribution in a material? I’d like to create a shader that uses the light contribution to sample a gradient, a kind of gooch shader effect.

Not sure on how to go about that, but you could try the following setup to get a (somewhat) similar effect:

In the material editor, create two colors (one darker, one lighter with a hue you like), then create a fresnel node. Finally create a lerp (linear interpolate) node and hook the whole thing up as follows:

  • The darker color goes into A of the lerp node
  • The lighter color goes in to B of the lerp node
  • The fresnel goes into the alpha port of the lerp node
  • Hook the lerp node into the materials Base color channel

You can also tweak the fresnel parameters a bit. E.g. “Base reflect fraction = 0” and add a bit of metal / roughness to your liking.


Thanks IMX, setting up a faux rim shader was the next step I was after so I can definitely make use of your advice, but what I’m after is the ability to map colour to luminance using an arbitrary gradient. The process would be something like:

> Get total light colour
> Convert to luminance (0.3 * R + 0.59 * G + 0.11 * B)
> Clamp to 0 to 1 range
> Sample gradient texture where U = 0, V = luminance
> Return total light colour * sampled gradient texture

i’m nor really sure on how to go about getting the “total light color”. That would include any contributing light in a scene / level, correct? And this would also need to change dynamically if the material is not at a static location in the scene, right?

Intriguing problem :wink: Let me know if I’m on the right track with my assumptions above.


Yeah total light colour would be lightmap.rgb + deferred.rgb. I’m not all that well versed in how the deferred lighting pipe works, but I am assuming (perhaps incorrectly, feel free to correct me) that by the time we get to the pixel shader, the lightmap.rgb and deferred.rgb lighting contribution buffer are both calculated and sampled within the shader code to provide total illumination for the given pixel. So it seems like it should be accessible in the material editor (though perhaps it isn’t exposed via a node).

I support the thought that at pixel shader level the info you want should be available, although I must say I haven’t yet seen a function that allows to access this information. It’ll be definitely possible in code. I’ll have a look into this…

Let me know if you find any BP function / node which allows access to the render pipeline in the discussed matter.


Only translucent or post process materials have access to those versions of the lighting data because of the deferred lighting pipeline. You should be able to throw down a scene color node and choose scene lighting or world normal etc. but you would have to set this up using post processing and use the meshes you want to have effect to render a custom depth pass.

We do stuff like that on Fortnite to do material FX on certain characters without their shaders having to integrate the material changes necessary.

Thanks Ryan!

Hi,RyanB gentleman, How to get the “total light color”? please told me the way. very thanks.

This thread is a few years old now and that method will no longer work.

The newer, better way of doing something like this is to use the new Volumetric Lightmaps feature. It will not be exactly the same, but it provides a more robust and featured way to accomplish similar results.