Stencils that you can use to view certain places

There are many addons that use (what I think is) stencils to show you a different portion of the world, such as the Tardis addon and many of the Portal Gun addons (with the portal entities).

My question is, how would I achieve the effect all these addons use? If I had a vector and an angle for a position that I’d like to be shown, how would I show it?

Or to be more specific (and make it even more complicated), I’d like to know if it would be possible to make the skybox of any map (probably using traces to find the bounds of the skybox or something as I assume there’s no straightforward way of doing this) show a place in the normal-sized world (maybe there’s a texture you could use?) Also, to avoid insane lag, would it be possible to make the skybox show it’s regular texture after one layer of the regular world (if that makes sense)?

I’m fairly certain that it’s not done by stencils only but by the render library in general.
Stencils are used to do the comparison whether some elements should be shown or not - such as drawing a rectangle where view of other place is being rendered, then applying a circular texture to it and running the stencil comparison so the rectangle isn’t shown outside the circle (thus the effect of a portal).

Rendering that place without doing some stencils would just make the whole portal a rectangle.

-snip nevermind-
I’m not that worried about the shape of the portal-I’m not trying to make another portal addon or something- I’m just trying to get the skybox to look like it’s inside a certain location.

[editline]30th August 2015[/editline]

Actually, this explanation will probably make more sense-

I’m making an Earth entity and I’m trying to think of things I could add to it- and then I thought- what if you could see whatever the Earth entity can see (from a certain vector/angle on it’s surface, which is defined by a convar), so to speak?

It’d be so cool to look up at the skybox to see the result of the Earth being inside the Earth…