I’ve spent some time on R&D focused on resolving a few important problems with FPP weapon/hands in UE4. A material node that I’ve implemented is an (I believe better) alternative to commonly used “Panini projection” node known from Unreal Tournament project.
Problems that my node solves:
1. Lack of separate weapon Field Of View (weapon stretching)
Standard solution “Panini projection”: Bad stretching, no control over the field of view, animators can’t see the result. Not clear license terms (Unreal Tournament source).
Standard solution Separate render pass for weapon layer: Requires engine modifications and can be slow/problematic with AA.
My reprojection: Node calculates the vertex offset as a difference between the mesh projected on the screen with in-game camera FOV and the weapon FOV. The result is unprojected into in-game camera space. It means that weapon mesh is stretched in axes X and Y to look like rendered in another FOV. In comparison to “Panini projection” mesh stays in the same shape independently of camera FOV.
Shadow mapping can be little inaccurate on the weapon.
2. Weapon render depth priority (environment clipping)
Standard solution: render weapon to additional stencil buffer/separate pass and render during post-process to prevent intersection. Slow and requires stencil buffer that should be used for a higher purpose.
My solution: scale the depth of mesh vertexes in the camera space – you decide how flat your weapon will be to not intersects with the environment. Mesh looks the same on the screen.
DOF will probably not work properly on the weapon.
3. Near plane clipping
Standard solutions: change the near plane value (UE4 don’t give this functionality), it can cause another problem with calculation precision and z-fighting
My solution: just move vehicles in front/back of the camera
4. The transition between the weapon FOV and the world FOV
My solution: Additional blend parameter that can be changed dependently on distance from the camera.
Right now I have a proof of concept and my method works correctly in UE4 so I’ve decided to show the results applied onto First Person Template.
The material is very fast and works on mobile without any additional changes. I’m going to explain step by step how it works in the article on my site very soon. Full implementation with examples will be available as a material package in the marketplace too 🙂