Hiding all objects behind transparent object

For a diorama-like scene I want to make everything outside of a certain distance from the center transparent (or the color of the background). I have achieved this using the Distance Node and the SmoothStep node. However, when I rotate the camera behind an object, the object behind this object is still visible. See image.


Floor object still visible through the invisible box.


Current node setup (Vector3’s in bottom left are 1,0,1 and 0,0,0)

Before using transparency to do this, I achieved the result I’m looking for by setting the pixels outside of the radius to the color of the background. But once I implemented a dynamic/procedural gradient skybox, I couldn’t do that anymore because the background isn’t a single color anymore.

How can I hide the floor when looking through the transparent part of the box? Alternatively a way of getting the right background color would also be fine.

Added a picture of what I try to achieve.


Desired result. Copyrights to Lockpickle Games

On top of that, there is also some weird clipping going on when looking at the intersection of the box and the floor from some angles. I suspect this has something to do with the transparency rendering after the opaque parts.

1 Like

UPDATE!!

Seems like I found a dirty fix! I just added the Skybox Material as a second material to the object. This seems to work very well with the transparency of the first material, however, this gives me a big warning about more materials than sub meshes…

Any ideas how to fix this?

Error and result: 2-C36-E546-A7-A4-4-F6-C-96-D6-E146-C934-D450 hosted at ImgBB — ImgBB