I's there a way to make a material such that when viewed through another object it appears differently?

Example: object 1 is a black sphere Object 2 is a glass plane

When viewing the black sphere through the glass pane the sphere becomes translucent, or in some way changes the texture that is visible THROUGH object 2, but anywhere that object 1 is directly visible to the camera it remains a black sphere.

Is this even possible using standard blender tools or will this require scripting and mods?


3 Answers 3


If you want this to work only on specific magic glass, this cannot be done with shaders and is very difficult and time consuming with render layers:

  • shaders have no clue which glass it is looked through, it reacts to all of them or none of them.

  • render layers have problems with refraction and transparency and influencing other (background) objects if the xray material emits light. Also intersecting x-ray objects with non-xray are a problem. The materials setup for them are complicated and dependent on object indexes and worth a separate answer if you want to know. It's basically setting 2 render layers to output the same as below.

The solution is to use multiple scenes:

  • 1st one normal
  • 2nd one duplicate with all "x-rayable" objects having x-ray shader

Then you just composite them together through a mask from the magic-glass. So the magic glass is like a portal window to an alternative world with x-ray objects:

enter image description here

Oh no! There are Suzannes trapped inside those spheres.

To save some time rendering you can make use of adaptive render region addon in the 2nd scene and render only around the magic-glass object.

Also if there is no visible light (direct or indirect) coming through or reflected off the magic-glass into the 1st scene, it's good to give it just plain black or holdout shader, so it renders faster. It will be replaced with the 2nd scene anyways.


There are several ways to approach this, the most flexible is likely compositing and renderlayers. However, it is possible to do this from within cycles:

enter image description here

If the incoming ray has bounced more than once and it is coming from a transmissive object (such as glass), it will be translucent. Otherwise it will be diffuse.

  • 4
    $\begingroup$ You really are a wizard. Your name couldn't be more appropriate. $\endgroup$
    – leigero
    Jul 1, 2015 at 20:54
  • 2
    $\begingroup$ Not to make this more complicated, but what if this effect were intended to work only with the certain piece of glass? Perhaps there are several but only one has the 'spy' properties required to reveal the objects true nature. $\endgroup$
    – leigero
    Jul 2, 2015 at 13:24
  • $\begingroup$ There is a very nice tutorial on the light path node from Bartek Skorupa: youtube.com/watch?v=MTFxyNzI5EE $\endgroup$
    – ronald8
    Aug 15, 2015 at 16:01

I've thought about this and have 2 ways I have come up with doing this. You'll decide which one to do based on your skill level and if it's a multiplayer game or not. Either way it will require multiple scenes set up exactly the same except for the objects you want changed.

  1. If it's a single player game, have the game change the scene when the character puts the glass to his/her eye so that he/she see's the new scene. The easiest way to do this is just having the scene change to the new one and making the glass be a pair of glasses you can put on and take off.
    If it's a multiplayer one you can do the same thing, although it's more difficult because you have to make all the characters have 2 locations. One in the normal scene and one in the glass only scene.

  2. If you want to get real creative and are reasonable at coding you also could set it up so that the glass works as a video camera and have a camera in the second scene that will stay in a relative position in the second scene to the glass in the first scene. This way you can hold the glass up and see the normal scene around the glass and the changes through the glass.
    Again, if it is going to be multiplayer you are going to need to set the players up so that they are always in 2 positions, one in the normal scene and the other in the secondary scene.

Side note, another bonus to the 2 scene set up is you can set the second scene to have a mystic look to it so that it looks like the glasses are seeing through the dimensions, or you can just copy and paste the scene with your new changes so it looks just like the other, it just gives you a lot of flexibility this way.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .