Panini Projection on First Person Weapon

I noticed in the 4.9 release notes: New: Replaced experimental cylindrical postprocess projection with better but still experimental Panini projection.

It seems Unreal Tournament’s approach to removing FOV distortion on first person weapons uses Panini Projection: “All first person weapons have panini distortion applied so they look consistent regardless of FOV” (A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums)

How can I enable Panini Distortion on my first person weapons in 4.9 to make their perceived FOV independent of the games FOV?

Reviewing the code its not so clear :\

Any suggestions would be greatly appreciated!

UT has a Custom GameViewportClient class which modifies the projection for the weapons, so that’s where to look. Naturally it requires a fair bit of code to implement.

Does UT is just using the panini projection only on the FPWeapon?

There is a panini projection postprocess - Panini Projection | Unreal Engine Documentation
This might be what you are looking for.

It even states at the very bottom of that page:

Which should be possible without a custom GameViewportClient. So not sure whether that page is outdate or not.

The reason they’ve also overridden the viewport is to place muzzle effects etc at the correct location I believe. it’s all very well transforming the projection but everything else needs to follow suit.

That’s neat. thanks.
I’m not too familiar with this technique but does that method is equivalent to set a FoV for the FPWeapon and have another FoV for the other assets?

Sort of, basically the Weapon has a consistent appearance regardless of FOV, along with anything else you apply the vertex shader too. The Post-Process version will affect everything on screen which you probably don’t want, since it’s pretty weird.

I’m applying it to a cockpit mesh for example, so the world outside the cockpit distorts based on FOV, but the cockpit mesh itself doesn’t.

ok that’s great.

We have some issue on FoV at the moment with our FPWeap and this technique will help to find a solution for sure.
Did you use the UT approach for your cockpit? or is it a simple mesh that you solve with a Material Function?

I’m going down the UT route.

My general rule is if Knepley or Polge have written it, it’s pretty **** solid and there’s usually good reason they did it the way they did :wink:

Excuse my blasphemy but I don’t really see the point of handling one thing in the material while everything else is done in code. If you’re already writing your own GameViewportClient you might as well take care of and adjust the weapon meshes as well right?

There’s no separate rendering channel you can draw the weapon mesh in, so that deformation of the mesh has to be handled in the material. However, it won’t actually move anything like the mesh sockets, so you need to transform those locations to the new ones.

I’m going to check, but I’m fairly certain that’s the case anyway and there’s no ability to render a particular object with a different projection style directly in the viewport.

Wow, this came just in time. Played around a little with the Panini Projection and it does help with the distortion. The blurriness is there too so that leads me to think I’ll need to review the UT Github’s repository and study what they did. I haven’t really played around with UE materials too much so this looks like a good time to do so.

Ideally I’d like to render one set of geometry into the backbuffer with one projection matrix, and another set of geometry with a different projection matrix. But I gather from your statement above that’s probably not an option.

That explains my confusion I assumed they just change the projection style in the viewport. Thank you very much.

Although I’m pretty sure I saw options regarding different projections like perspective versus orthographic in the camera components somewhere. I’ll probably look into the source code and see where that’s used.

Yeah you can change the projection of a camera, but again that affects the entire scene not just a single object.

Did anyone ever have any luck with this?

It’s done in the material it seems, so you can just look at the UT materials.