Help creating a viewing portal to another world shader

Hi all I’ve been going at this for days now, and I have seemed to get close but fall short

What I’m trying to accomplish

  • A shader which is modified to be hidden (this has a reference value of 117)
  • A cube which has a shader that reveals anything with the reference value of 117 both looking in and out of the cube
  • Anything revealed when looking from inside the cube will render on top of any object physically out of the cube and doesn’t share the 117 value

I managed to get the first 2 points working however random objects and walls in my scene are still appearing
The desired effect is to create a viewing portal, where anyone or anything outside of the viewing portal won’t be seen.

So, for example, I’m in a lab and when I step inside a viewing portal/box I only want to see the landscape and mountain I’m standing on. The issue is that the lab will still render.

Odd requirement but this has to be done exclusively through the shaders, sorry about that.

Thanks in advance

Make sure the cube’s material and/or shader has a render queue that’s lower than the objects you want to hide. This means either lowering the queue of the cube, or increasing the queue of the “lab” materials.

Heyo, no luck

I tried that but seems to not work
The realspace (lab) render queue is 2450
I set the viewbox to render queue 1998
and the environment at render queue 1999

I played around with zwrite

on

The sphere here is supposed to be hidden (Sphere is in realspace/Lab)

off

Nothing outside of the cube is rendered not even the environment

Note the white border on the floor, that’s my cubes border
The sphere(part of real space) is still rendered when it shouldn’t be

I tried the overlay queue for the viewing box’s shader but no change