Light incidence node

In Cycles, I’m trying to get the light incidence on a surface either as a value or a color.

I’ve got the suggestion of using a white diffuse, but it won’t output colors, just the shader connector (green), and it doesn’t work as color (yellow) or value.

I also tried to write my own scripted node, but I soon realized that the the green connectors output “closure” color info, which can be manipulated but can’t really be accessed in any other way, so I’m kind of hands-tied.

Any idea?

Use Blender Internal.

In Cycles, the purpose of rendering an image is exactly to know the amount of light that hits an object. If we knew that in advance, we wouldn’t need to render the image at all.

It’s a Cycles project. Unless there’s a way to mix information from BI, this is not an option. :frowning:

I didn’t understand. I mean, every package I’ve worked so far has got either internally or as a plugin an element that serves as a probe for the incidence of light (at least direct light) as a map.

With nodes, you can’t. Not at rendertime or without some serious faking. If it’s crucial to respond to actual complex lighting, I’d prerender the object and read it back later as camera or screen coordinates. I’ve never tried this though, would probably get messy if reflected and so on. If it’s to gather info from a single pointlight (single point in space, not a spherical ball light or area light), for say some fake light angle dependent iridescence effects, you can reference an empty and do you light calculations manually.

Try diffuse and or glossy material override for the whole scene. Set max bounces to 1. Multiple passes though.

You can render your scene in two passes (or bake the direct illumination for the object you want this information).
And you can also mix the Blender Internal with the Cycles render, if you want.

In engines like Cycles, the amount of incident light (either direct or indirect) is the main purpose of the algorithm. As CarlG said, you can put the light direction and distance into the shader, but this is «serious faking»; and will make your shader improper for any other scenes.
The ‘cool’ thing about Cycles materials is that they are, by default, light independent; that way you can reuse the same material in any different scenes or lightning enviroments, and still get the expected result.