If you don't mind using OSL (that is, setting the render to Cycles/CPU, and checking the 'OSL' option) then you can look ahead down a ray, using a script. This script returns the Pass Index of the next material encountered, continuing in the direction of the incoming ray, (so it won't, without improvement, take refractive/reflective deflection into account) #include "stdosl.h" shader NextIdx( output float nextIdx = 0.0 ) { if (trace(P,-I,"mindist",0.00001)){ getmessage("trace", "material:index", nextIdx); } } .. and can be used in a tree something like this, to make the 'glass' of the lens: [![enter image description here][1]][1] .. where, in the example, the eye material has an Pass Index of 10, and everything else has an index of 0... producing.. [![enter image description here][2]][2] so the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else. [1]: https://i.sstatic.net/DB927.jpg [2]: https://i.sstatic.net/dK9Kk.jpg