Remove mesh from camera but keep its reflections for other objectes

Hey there,

I have a black plane in the background and an translucent, glossy 3D model. Due to the transparency the model’s apperance is obviously different. I want to keep said effect, but remove the plane from the camera.

For demonstration purposes I simplified my problem and replaced the 3D model by an translucent box:


For reference, without plane, box appears lighter:

I want the plane to be still reflected by the box, but invisible for the camera.

Plane:

<mesh scale={[viewport.width, viewport.height, 1]}>
  <planeGeometry />
  <meshBasicMaterial color="black" />
</mesh>

Object:

const Object = () => {
  const { scene } = useGLTF("/foo.glb");
  return <primitive object={scene} position={[0, -0.5, 0]} />;
};

Is this possible? Do I need to find a different approach to achieve the same effect?

Thank you!

Doing that “the right way” may be quite hard, since the render target used for transmission / translucency / dispersion / IOR rendering is hardcoded directly within renderer.render function.

If it’s a matter of having the model brighter / darker, would maybe setting .color on model material to something darker than 0xffffff help?

The render target used for PBR transmission wouldn’t be relevant for alpha blending (material.transparent=true). Can’t tell what type of transparency is being used here without more information though, if it’s PBR transmission then I’m not sure.

Assuming alpha blending — one option would be to use the stencil buffer and custom render order to:

  1. draw the model first, writing only to the stencil buffer
  2. draw the plane, only where the stencil buffer is already set
  3. draw the model again, normally

Similar to the approach suggested in this post:

Note that what this approach allows is to continue drawing the plane, but only where it lies directly behind the object, and not elsewhere. I think that’s what you intend?