Determine the direction of light hitting / bouncing from surface

Hi all,

Thanks for all the great help this forum has been over the years. I hope you can help me.

I am trying to find a way to determine the direction of light interacting with a material, so I can make it (for example) more glossy, or a different colour when viewed from one direction compared to another.

This should not just be a function of the camera position in relation to the surface, because the resulting bounces should affect other objects / materials also.

I’m assuming this may only be possible through a python script / add-on - which I would be happy to pay for as that’s way beyond me!

Any help or ideas would be gratefully received!

Basically, you can’t. Tracing and light evaluation is done in the shader stages of a material, which happens last (except for the actual output), and you can not influence what goes on in here. The only way I can think of is a cheat where you can setup a dummy object and obtain its coordinates/location for dummy shading purposes. That won’t work for complex light sources, and may be a hazzle to setup for many light sources.

is there a way using OSL may be ?

happy cl

The problem remains the same in osl. A shader cannot know in advance any light locations. That’s up to the render.
We can feed some directions to the shader, but only manually, or outside the render part, as in the link i posted… And even so there are limitations, like knowing if there’s something causing a shadow, or if the light is bouncing from another surface.