I’ve spent some time doing 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 Panini projection node known from Unreal Tournament project.
https://www.youtube.com/watch?v=OpE0UypSzng
Problems that my node solves:
1. Lack of separate weapon Field Of View (weapon stretching)
“Panini Projection”: Bad stretching, no control over the field of view, animators can’t see the result in editors. Not clear license terms (Unreal Tournament source).
Separate render pass for weapon layer: Requires a lot of engine modifications.
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 projected into in-game camera space. It means that weapon mesh is stretched in axes X and Y to look like rendered in another FOV. Mesh stays in the same shape independently of camera FOV.
Tradeoff:
Shadow mapping can be little inaccurate on the weapon.
2. Weapon render depth priority (environment clipping)
Standard solution: Clear depth and render weapon in a separate pass to prevent intersection. Requires engine modifications.
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.
Tradeoff:
- DOF will probably not work properly on the weapon.
- The intersections are possible but rare
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.
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.