3

Is it possible to get the distance a ray travels inside an object with cycles material nodes?

enter image description here

Then map it to a 0-1 range to create a map:

enter image description here

E.g. to adjust the color of a Glass node to make it more transparent where there is less volume between the camera and light:

enter image description here

How can I do this?


The example images above were rendered with the Layer weight node. This only works on spheres.

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133

1 Answers1

3

It is always the way you ask. Ray length is the distance from previous bounce or refraction.

What might be a bit confusing - you have to apply toning to the inner side (backfacing) of your object, because outside rays return distance from other objects - as ray begins from camera, not from light source.

As far as mapping goes - approaches are different - for instance: http://lesterbanks.com/2012/10/using-blenders-raylength-node-to-create-a-re-usable-custom-absorption-shader/

kivig
  • 623
  • 4
  • 13