7
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ With a cube, it wouldn't be necessary, but in some situations, OSL might help $\endgroup$
    – Robin Betts
    Sep 7, 2019 at 18:40

2 Answers 2

7
$\begingroup$

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

$\endgroup$
3
  • $\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$
    – snipers500
    Sep 7, 2019 at 15:43
  • 1
    $\begingroup$ Could work with only one cube, I think. using intersection and difference. $\endgroup$
    – lemon
    Sep 7, 2019 at 17:05
  • $\begingroup$ oh yes of course, I'm going to correct $\endgroup$
    – moonboots
    Sep 7, 2019 at 17:11
10
$\begingroup$

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

$\endgroup$
7
  • $\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$
    – moonboots
    Sep 7, 2019 at 16:26
  • $\begingroup$ @moonboots, don't get what you mean $\endgroup$
    – lemon
    Sep 7, 2019 at 16:33
  • $\begingroup$ Could you please share your file? $\endgroup$
    – moonboots
    Sep 7, 2019 at 16:35
  • $\begingroup$ @moonboots, sure: updated above $\endgroup$
    – lemon
    Sep 7, 2019 at 17:04
  • 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$
    – moonboots
    Sep 7, 2019 at 17:10

You must log in to answer this question.

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