First person renderer

We first showed this off on Twitter in early February, but like many things in Peripeteia, the early versions are often proof of concepts before we begin to actually implement them. I’ve finished doing that now, so it’s a good chance to write a nice blog post about it. A new first-person renderer is feature that’s been asked for quite a bit after releasing our first demo, primarily because the way we handled the in-hand models for weapons caused clipping issues, and was inconsistent over various camera fields of view.

Gun at FoV 60. For some guns, the models weren’t visible at the value set so low. AK looks good though!
Gun at FoV 100. Looks distorted and unappealing.

Most first person shooters on the market render the weapon model from a separate camera, which is efficient and easy. There are, however, some issues to that approach when working in Unity. First of all, rendering in-hand models for guns on a secondary camera doesn’t allow use of real-time shadows, which is quite important in Peripeteia. While the light meter is a useful tool, sometimes it’s just quicker to make use of the body awareness we’re going for and take a quick glance on Marie’s legs or at the gun.

Gun rendered on separate camera, lit by a light source behind the wall. Not an issue in a typical shooter.
Gun as rendered in Peripeteia demo. Proper shadow maps but it has its problems.

This method of rendering was the one shown in early February and it quickly turned out to be insufficient. The official Unity way of resolving the problem of no real time shadows on weapons wasn’t adequate for us either, unfortunately. Unity suggests placing a set of tiny weapons and hands in front of the world view camera. While this sounds like a joke at first glance, this is a great method for disembodied cameras that don’t show the rest of the character or have them cast shadows, using the same model as in third person – like we do.

To our rescue came this handy asset, which is highly recommended: First Person View 3 by Drunken Lizard Games. In the early days of Peripeteia we decided to not use any store bought assets for budgetary reasons (as in: we don’t have a budget), but the generosity of our patrons allows us for such purchases.

The asset itself only provides you with a set of shaders to use on your weapon and hands- which is great as it gave me a lot of control (including the ability to modify them in HDRP sharer graph), although the process of implementing it took a bit longer than expected. Thankfully, now Peripeteia will have proper first person weapons!

What was achieved?

No more weapons clipping with the environment. While the player controller has been set up to minimize such instances, when getting close to objects such as desks, or when leaning to walls, the weapons would disappear inside them.

AKs clipping into geometry take away from the immersion
Current weapon model

A separate field of view for each weapon. This allows us to consistently position the gun on the screen, for the most aesthetically pleasing effect – independently of the field of view set by the player.

Current weapon view at FoV 60.
Same shoat at FoV 100. The way the gun is displayed stays consistent.

A better sight picture when aiming. Without previously being able to control the field of view of the gun camera, guns using scopes had limited visibility, which caused problems even with the relatively low power optic of the Polon rifle. Another issue was the camera plane clipping into the gun models, which doesn’t happen anymore.

Polon scope as seen (through) in the current demo
New Polon sights
AK clipping into the camera when making abrupt movements

Current behavior of the AK

While this is a fantastic asset, the fact it renders the guns and hands at a different field of view than the rest of the environment causes a single problem: the way their shadows are projected. With the default settings, a shadow of a disembodied set of hands holding a gun would accompany you. This has been fixed by applying a different set of invisible shadowcasters to each object that switched its renderer to the custom one.

Seeing your shadow without arms would probably take away from the immersion as well.
We F.E.A.R. now.

One last thing I’d like to write about is a small detail that will likely not be noticed but that I’m very proud of. When firing the gun, casings ejected by it will be rendered at the same FoV as the gun itself (default 60), but at they fly, the FoV they are rendered in is changed to correspond to the world camera. It looks pretty trippy in the editor view and is quite seamless in-game, even when showering a nearby wall with brass.

Hopefully this demonstration is sufficient to show how it works.

Post list