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:
2 Answers
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.
-
$\begingroup$ Thanks, I ended up using this method, (which also happened to be the way I made the reference image, so I'm just dumb) $\endgroup$ Commented Sep 7, 2019 at 15:43
-
1$\begingroup$ Could work with only one cube, I think. using intersection and difference. $\endgroup$– lemonCommented Sep 7, 2019 at 17:05
-
$\begingroup$ oh yes of course, I'm going to correct $\endgroup$ Commented Sep 7, 2019 at 17:11
An update, thanks to moonboots comments:
It is possible using Cycles:
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):
-
$\begingroup$ I thought you had the solution but actually what you propose is to display another texture through the cube transparency, which is not exactly what he's looking for, at least it's what I understand $\endgroup$ Commented Sep 7, 2019 at 16:26
-
$\begingroup$ @moonboots, don't get what you mean $\endgroup$– lemonCommented Sep 7, 2019 at 16:33
-
$\begingroup$ Could you please share your file? $\endgroup$ Commented Sep 7, 2019 at 16:35
-
-
1$\begingroup$ so yes, that's what I thought, actually the new texture is not displayed at the objects intersection but where the transparency happens, which is not the same... On the left what is supposed to happen, on the right what happens with your method: zupimages.net/up/19/36/tl1c.jpg $\endgroup$ Commented Sep 7, 2019 at 17:10