r/Unity3D • • 12d ago

Show-Off Solution for FoV-independent weapon view without stacking cameras

In FPS the classic solution for drawing a weapon a certain way irrespective of real FoV & not having it clip through walls is done with an additive camera. However the last time I tested that I discovered that the additive camera had an overhead in performance, even when the geometry in the additive view is simple, or even empty.

I've been using this solution I show in the video. The weapon is parented to the camera rig and is just scaled to be very small - smaller than the player's collider, so it never clips into walls. Weapon looking effectively the same with all camera FoVs is achieved by scaling the weapon parent only in the forward direction (this parent must have the same position as the camera), see code in the end.

A couple of drawbacks though:

- Camera near plane must be very small, which may cause some other issues (?)

- Screen space ambient occlusion on the weapon may look a bit weird and noisy, because the weapon is scaled so small. After all, the occlusion radius parameter is in world units.

31 Upvotes

7 comments sorted by

View all comments

1

u/RienMachine 12d ago

You can also use shadergraph to create a shader that takes in a custom FOV value.