adding render passes/rendering with stencils

Im trying to make a portal clone im ue5, unlike the original portal, im currently rendering the portal with a scene capture component and render textures. However I wanna try to render the portals the same way portal, the game, renders its portals by using a stencil buffer. link to video talking about it: https://youtu.be/riijspB9DIQ?si=5_DZH-2AvjSz-Vez&t=576

I wanna know if its possible to do something like that? adding a passes to the renderer to render the portal view. Maybe I can use something like a ‘FSceneViewExtension’ or modifyfing the main ::render() function?

Now with ‘its possible?’ aside, I know very little how rendering works, I read about, looked through the engine code, but I have very little understanding on how it works. if possible, id love some resources I could take a look into to learn more about it.

English is not my first language sorry if theres any mistakes in the question.