[????] Making a window that you can see nothing but sky box

Is there a way to make a window that when you look through it, things out side of it will be invisible, also, as long as the window is in the game view, whatever through it remains invisible?

As you can see it the picture, the ideal result will be you can only see skybox through the window but there are actual object behind that. And when you move the charactor, the skybox you see from the window will change, not just a static picture.

I have been thinking of the solution for many days. It is pretty much like the opposite of occlusion mask, but I don’t want the whole object not being rendered.

[79749-捕获.png|79749]

One way of doing it would be to simply have the window use a shader that renders as if it were a skybox, i.e.

Shader "Custom/Window" {
    Properties {
        _Skybox ("Skybox Cubemap", Cube) = "" {}
    }
    
    SubShader {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Lambert noambient
        #pragma target 3.0

        samplerCUBE _Cube;

        struct Input {
            float3 viewDir;
        };

        void surf (Input IN, inout SurfaceOutput o) {
            o.Emission = texCUBE (_Cube, IN.viewDir);
        }
        ENDCG
    }
}

Which you would put on a plane where the window would be. If you want to do a proper object mask, you could use a stencil shader but they are much more advanced.