Individual near clip plane per camera/oblique near plane clipping/editing camera's projection matrix

I’m trying to make a portal system similar to that of the Valve game, and I’ve got everything working except for the clipping of objects between the scene capture camera and the portal.

What I really want to do is oblique near plane clipping, but it looks like getting to mess around with a camera’s projection matrix will need me to build the engine from source, which I’d rather not do.

At the moment, I’m literally just iterating through all the objects in a scene, and hiding them from the scene capture component if they’re on the camera’s side of the portal, but this is very clunky and breaks in some circumstances. Is there any way to edit a camera’s near clip plane without changing it for the entire project?

I saw something that got me almost there in this thread: Howto modify the projection matrix - Programming & Scripting - Epic Developer Community Forums

But that looks like it only works for player cameras, and I’m trying to edit the projection matrix of a camera not connected at all to a player’s.

Hi Leo,

I’m currently also trying to create a portal system in unreal.
Could you help me out a little bit please?
What are the steps to get the portal rendering done? I don’t know where to begin.
I just need a starting point and a rough explanation what’s needed at all.

I would be really grateful over an answer.

Best
Dennis

This link should get you going for the portal view part DepthMasks and Portals? - Pipeline & Plugins - Epic Developer Community Forums

One thing that link is missing is that you’ll probably need to change a blending mode somewhere. I did it a while ago so I don’t remember exactly what, but if your portal view is much darker than the world view, that’s probably the reason.

For the camera control, make sure you set pawn controller to control pitch as well as yaw, or else you’ll get stuttering, and also make sure that when you’re testing you use the same aspect ratio as the texture or it’ll look off.

I never got an answer to the question here, but an ugly hack way to deal with it is to get every object behind your portal view and set it to not be rendered by the scenecapture2d camera (excluding the floor and walls). It’s not perfect, so if you find a way to actually use near plane clipping, let me know.