How to render only what's visible in one room

Hi, I want to do a little adventure game that happens in a house.

I found some nice concept art I want to base my game on.

As you can see on the picture, the adjacent room is only visible from the current room’s perspective. The rest is culled.

Any suggestions as to how I could achieve this effect?

Ok, I found out where I have to look into, which is already solving a big part of the problem.

There’s a thing with shaders called the “stencil” which you can use to do all kind of things

So I created two new shaders: one which will input data to the stencil buffer, and one which I applied to all my objects on the scene, which discards all the pixels that don’t match the stencil buffer.

All I had to do was to add a couple of lines in the shader.

To input data to the buffer:

		Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
		LOD 100
		ColorMask 0
		Zwrite off

		Stencil {
			Ref 1
			Comp always
			Pass replace

and to do the culling:

		Stencil {
			Ref 1
			Comp equal
			pass keep

I applied the first shader to a cube that completely covers the room I’m currently in

and the second shader is applied to all objects in the scene that are to be rendered

here’s the result