3
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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/

$\endgroup$
  • $\begingroup$ I watched that video a while ago, but I never was able to get satisfying results.. $\endgroup$ – gandalf3 Oct 26 '13 at 23:04
  • $\begingroup$ I have been playing around with this technique and also this one from blender cookie, and I think I have better idea how to use these techniques now. Thanks $\endgroup$ – gandalf3 Oct 28 '13 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.