Distance from emmision

Hi,
I’d like to visualize color based on distance to emission
For blender render it is simple node configuration:


I’d like to do the same in cycles, because I want to use area object (not simple point) and my problem is that, I can’t fo find distance to emission.


What should I use insted of Light Path?

Is anyone could help, please? :slight_smile:

Attachments

Cycles render.blend (480 KB)

The setup is correct! the problem is the logic behind it.

Your Plane’s material should be a normal material (diffuse, glossy, etc). The Light, however, is the one that has to have this functionality. Basically what we want to do is for the light to have a blue color when the ray that hits it is smaller than 15, and a green color otherwise.
Technically, when the render picks a point to render and it hits an object, it will then try to reach any light from the hitted point. This ray will carry the RayLenght from the point being rendered to the light, and then the light can ‘choose’ if it should be blue or green. After this, the render calculates how much from that light will hit the object and reflected to the camera.

So in your Scene, replace your light material with the Material.001, and give the Plane a simple diffuse, and you’ll see it working ok ( In your scene you should set the strenght to a higher value :slight_smile: )

Hello,
It works. Thanks a lot :eyebrowlift2:
Now I only have to figure out how to simple ramp a colour like in blender renderer.

Thanks a lot, once again :smiley:

The ramp can be a simple mixRGB (for 2 colors), or a ColorRamp (for more colors).

Since the input factor of both nodes should be in the interval [0, 1], you may need to divide the Raylenght by some value.
This should be the max distance, since if Raylenght is equal or greater than Maxdistance, then output will be 1 or greater, thougth either mixRGB and ColorRamp will clamp the input factor to 1.

Your clues were very useful.
Thanks a lot, once again. :smiley:

What about doing the same based on angle between lamp and plane normal, at point where light hits the plane?
I mean, if angle is greater than some value, it should be yellow, if not blue.

Any sugestions?
Help, please :o

It’s possible to have the light with different colors based on the incoming ray direction, but not based on the objects surface because the ray doesn’t carry the normal from the point being sampled. It may be possible using OSL by making a trace() in the incoming direction, thought I don’t recall if the message can also return the hitted normal :confused:

Hmm, so it’s more complicated then a supposed. OSL it’s out of my range :no:
Thank You for answer.

In some scenes, this is still possible to achieve; for example when you have just one light source as a pointlight or a sunlight. But you have to encode the shader with the light position and direction, which makes your material very specific for each light setup.

Any suggestions, with nodes should I use, please :smiley: