LayerWeight/Fresnel based on light position instead of view angle


I would like to have a LayerWeight/Fresnel node - but instead of taking the viewing angle/camera position into account, it should be based on the position of the light.

Probably it would be possible to use some vector math to achieve this, but I don´t find a way to get access to the light position in the node tree.

Do you know, if this is possible and if yes - what would be the best approach?


Nope, that’s not possible - shaders in Cycles are evaluated once per surface hit, and the resulting BSDFs are used for potentially multiple lamps (when using Branched Path Tracing) as well as for sampling the outgoing direction.
That’s one of the fundamental limitations of Cycles’ shader system (and of every renderer based on OSL).

You can kinda fake it if you are dealing with a single lamp or mesh light.

Using the node setup in this thread - you can key the material off the position of the lamp

Of course the material isn’t actually responding to the light - but rather the position of the object emitting the light - but it may get you part way to the effect you are after.

ah, thanks - so my fear comes true :wink: But the Heat-map-effect looks interesting and might serve me as workaround, thanks for the link!