What would be be the best way to make a lit material only visible through a transparent mesh?

I’m essentially looking for the opposite behaviour of an AlphaHoldout material, where a lit mesh is invisible unless looked at through a transparent plane. I’ve managed to do this before, but not with lit materials.

I presumably need to use a masked material on the meshes to keep the lighting, then somehow pass custom depth data to its opacity mask pin. But the only way I could think of doing that is with a Blueprint and an MPC, which can only send scalar and vector data and not even on a per-pixel basis…

How could I do this?

you use an opaque mesh duplicate to block in the depth into the custom depth buffer. it doesn’t need to render in the main pass nor regular depth pass. but needs to be rendered before the mesh you wanna hide. the translucent material is just translucent. and the mesh you wanna hide has to be rendered as translucent to get access to the custom depth scenetexture. (i used forward to get material parameters to use) and you need a lil node setup to check if it’s behind the invisible “depth blanket”. that’s what you probably already had in mind.

you could probably render the glass pane first too using the translucency sort options. this way you would not require the xtra block-in mesh. i just did it the old school way that i know it’s guaranteed to work.

the same technique could be used with the custom stencil buffer. unfortunately the stencil test is not available for normal mesh rendering.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.