0
$\begingroup$

I'm looking to create a shader in Eevee where object A inside of object B casts a ray/projection/mask over a set distance towards the camera to mask out its shape in object B. Here's what I've managed so far:

1

2

3

This works to an extent, however it's important that the projected silhouette of object A on object B is sharp and accurate. For this example I've used face corner values. While it could be made sharper by kicking up the subdivisions, this is not ideal. Here's how it looks up close:

4

(In the past I've used compositing to achieve the effect I'm looking for but with that method I would have over 20 render layers per character, since the character had to be cut into parts for the masking to function as intended.)

Though my understanding of the Cycles engine is limited I think it might be better suited to create a shader like this, but I hope to stick with the Eevee engine since it works well in my workflow.

If anything is unclear, let me know. Any suggestions are appreciated!

$\endgroup$
10
  • 1
    $\begingroup$ Is that holdout "inverted"? $\endgroup$
    – Crantisz
    Feb 27, 2023 at 10:36
  • $\begingroup$ Are you asking if it would be like an inverted holdout? I think so, in the sense that it would reveal what's in front of it rather than hide what's behind it. But it should only do this over a certain distance, like with the model. $\endgroup$ Feb 27, 2023 at 10:52
  • 1
    $\begingroup$ Ray Direction should be a direction, not a camera location. This means that it should be subtraction from position from camera position. $\endgroup$
    – Crantisz
    Feb 27, 2023 at 11:06
  • 1
    $\begingroup$ @RobinBetts Hello, in case of an animated character, parts of the character(limbs, torso, head, etc) overlap relative to the viewpoint, meaning that in compositing for each part of the body two render layers would be required, one for the silhouette and one for the shape. Hopefully this image helps explain it. Imagine all the different possible combinations, each part of the body would require its own two layers: torso, head, upper right arm, lower right arm, etc... With a different character that got me to over 20 layers, with some simplifications. $\endgroup$ Feb 27, 2023 at 12:32
  • 2
    $\begingroup$ "Object A inside of Object B" - you don't show one object inside another. Is there something inside the sphere that's supposed to be visible? Can you manually prepare the effect you're going for, for a still shot? What you managed so far isn't very helpful if it just doesn't work. Do you want to create some kind of a camouflage effect? $\endgroup$ Feb 27, 2023 at 12:35

1 Answer 1

1
+100
$\begingroup$

Position the Holdout object in front of the UV object and use the transparent ray depth on the uv object.

Result

Obviously, this will break if there are a varying number of transparent object in front of the camera.

  1. Use Geometry Nodes to move the mask object between the UV object and the camera.
    geo node setup
    mask object appears to be in front from
    The mask object will appear to be in front of the UV object.
  2. Add a transparent shader to the mask object.
  3. Use the Transparent Depth as a condition for rendering the UV object transparent.
    UV Object shader

This only works in cycles rendered view. This hack can't be used for all objects at once sadly. Every instance of mask object and render object need to be rendered on a separate render layer.

$\endgroup$

You must log in to answer this question.

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