I am a little bit confused as to how this node works, mainly in terms of how some node setups have different output sockets being added together, as well as what is being measured for ray length, and depth.
The first thing that is quite hard for my brain to understand is, how it is possible to mix the camera rays and the glossy rays (like in the picture), as well as turn it into color information. How does the light path node convert the camera ray/glossy ray information into color information? This part stumps me, I can't quite visualize what happens here.
The other thing that stumps me is what is being measured for ray length and depth. In the blender manual, the ray length has this definition:
Distance traveled by the light ray from the last bounce or camera.
and the ray depth has this definition:
Number of times the ray has been reflected or transmitted on interaction with a surface.
From these definitions it is measuring 'a ray', my question is which single ray are both of these options measuring (or am I thinking about this in the wrong way)? From my understanding, aren't there thousands and thousands of rays that are bouncing around?
The light path Node scares many Blender users ;)
Everywhere it says: Is ..., it outputs either a 0 or a 1. ( False or true.) You can use a Color MixRGB to add the two, but then the Factor should be set to 1 (With your setup the Add outputs either 0, 0.5, 1, or 1.5). As a Color, that would be interpreted as Red Green and Blue all set to that specific value.
Much better to use Converter > Math Node, set to Add! This will ouput a value of 0, 1, or 2. When Clamped it just outputs 0 or 1.
In above example, it will out put 1 (which will use the Glossy Shader), when it is a Camera Ray, or a Glossy Ray, or both. In all other cases it will output 0 (meaning the Transparent Shader will be used).
If you would use a Multiply in the Math Node, the output would only be 1 if it is both a Camera and a Glossy Ray.
Also you'd usually connect the ouput of the Math Node to a Factor of a Mix RGB, or a Mix Shader.
For the second question: the Light Path Node doesn't calculate one single ray, but is evaluated for each ray individually!
I often just use the Light Path Node like this:
To get an Object that is lit by an HDRI rendered against a (in this case) blue background.
Also be aware that rays can have be of more than one type in the Light Path Node; for instance the Diffuse Rays and Glossy Rays both reflect light and are therefor both also Reflection Rays!
Wow! Thanks again for the informative reply. there is just one part that im still a little confused about, and its how blender interprets the camera rays and the glossy rays as rgb information (in the example picture that i posted above). This is what I assume happens, whatever the camera rays hits gets becomes white (equal to 1) and whatever is not becomes black (equal to 0). Then whatever the glossy rays hits becomes white, and whatever it doesn't hit becomes black. Then these two images get processed through the mix rgb node (with the add blend mode) and outputs and image?
Is this correct? Thanks again man, you've been really helpful!
The (a bit nonsensicall) way you have set it up, the Transparent Shader gets its Color from the Light Path Node. A Transparent Shader has no Glossy component, so only the Camera Rays contribute to that Color, but all rays start out as Camera Rays, so the Tranparent Node gets an input of 1 for the Camera Rays, which is being converted by Blender as RGB (1, 1, 1); pure white Color.
Then the Transparent Shader lets the light Rays through, so that they are no longer Camera Rays (as soon as a Camera Ray hits a surface, it gets reflected or transmitted or absorbed, but is no longer a Camera Ray) so the Is Camera Ray becomes 0 for all rays that have hit the surface, apart from the Glossy Rays, but a Transparent Shader does not have a Glossy component, so there are no Glossy Rays there (yet!)
Then you mix in a Glossy Shader with a factor of 0.1, meaning that 10% of the Camera Rays that hit the surface become Glossy Rays and they get added to the Is Camera Ray by 0.5, so Is Camera Ray + 0.5*Is Glossy Ray. So if it's a Camera Ray (before it hits the surface) the Transparent Shader gets a Color of (1, 1, 1), but when its a Glossy Ray (10% of the rays that hit the surface become Glossy Rays), this sum becomes 0.5, so the Transparent Shader gets a Color of (0.5, 0.5, 0.5).
One more thing, Shadow Rays are separately cast Rays and as they are not used in your Light Path set-up, they give a 0, meaning they give the Transparent Shader a Color of (0, 0, 0). So if you'd plug your Transparent Shader directly into the Output Node (without the Glossy Node), you'd see a shadow from your Object, but not the Object itself:
It's a bit complicated to explain, but I hope this helps a bit ;)
I can highly recommend 'The Cycles Encyclopedia' if you are interested in these things: