7

Let's say I have a sphere, halfway intersecting with a cube(which is invisible to the camera). I want to change the material of the part of the sphere that is intersecting with the box, similar to this image:

like this

snipers500
  • 469
  • 6
  • 16

2 Answers2

10

An update, thanks to moonboots comments:

It is possible using Cycles:

enter image description here

The shader simply tests if the transparent depth is at least 1 as the cube is transparent but also we don't want more than one (as if not the cube shape may appear in non ortho views):

enter image description here

lemon
  • 60,295
  • 3
  • 66
  • 136
7

You could create 2 spheres on the exact same position, each with its own texture, then 1 cube. Give each sphere a Boolean modifier, one with the Difference mode, the other with the Intersect mode, and both with the cube as Object. This way, when you'll move the cube, it will both hide a sphere and reveal the other one.

enter image description here

moonboots
  • 155,560
  • 7
  • 105
  • 171