# How can I make light that changes its color with path length?

I want to create a light source whose light colour will change with ray length.

Example:

 (light src)______________ | \ \_______ | \ \______ |(red) \ (green) \(blue) (plane)_______________________________________________________________ 

The node setup for the lamp:

• Ray length as input
• A power for tuning the value
• HSV node which shifts the input color depending on the ray length
• All connected to the color socket of the lamp

The plane which receives the light is just a simple diffuse shader.

An alternative configuration:

• thanks for comprehensive answer, but i wonder why do i need a separate object to get ray length information and not just create some node setup for a light source? – FanciestBanana Jul 24 '16 at 13:52
• Well... in fact, you can !! Sorry, my answer was bad : I rewrite all that ! – lemon Jul 24 '16 at 14:00
• @FanciestBanana, I have to say your question above helped me to understand the answer : )... – lemon Jul 24 '16 at 14:12