Skip to main content
added 2 characters in body
Source Link
Robin Betts
  • 78.8k
  • 10
  • 79
  • 199

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, and the lens is a single plane, without thickness.)

#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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description hereenter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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, and the lens is a single plane, without thickness.)

#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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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, and the lens is a single plane, without thickness.)

#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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

added 52 characters in body
Source Link
Robin Betts
  • 78.8k
  • 10
  • 79
  • 199

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, and the lens is a single plane, without thickness.)

#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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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, and the lens is a single plane, without thickness.)

#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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

added 17 characters in body
Source Link
Robin Betts
  • 78.8k
  • 10
  • 79
  • 199

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

.. 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

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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

.. 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

so the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

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

.. where the eye material has an Pass Index of 10, and everything else has an index of 0...

producing..

enter image description here

so in this example, the 'glass' is transparent to everything has a material Pass Index greater than 5, and diffuse grey to everything else.

Source Link
Robin Betts
  • 78.8k
  • 10
  • 79
  • 199
Loading