CurryKitten / CurryKitten-Sim

FPV quad simulator
70 stars 7 forks source link

Add the option to increase the FOV - but make it look right #5

Closed CurryKitten closed 4 years ago

CurryKitten commented 4 years ago

The sim is currently set with a fixed FOV that mimicks roughly an FPV camera, but one with a limited FOV. In terms of how Unity sees it, this is 60 degrees

Screen Shot 2019-12-08 at 10 15 56

Whilst Unity has a FOV control, this doesn't look anything like an FPV camera in the real world. Increasing the FOV to 100 degrees results in the front of the quad model getting stretched into the scene - which looks particularly awful.

Screen Shot 2019-12-08 at 10 16 26

Most FPV cameras tend to distort the image at the extents which give the effect of a slight fish-eye lens and results in the props looking like they are at a slight angle instead of being straight.

I think I need to create my own shader to attempt to replicate this, although quick and dirty workarounds may include the ability to remove props from the scene (for people who don't like them) or render the quad model invisible if the increased FOV looks ok (aside from the stretched out quad body)

CurryKitten commented 4 years ago

I've been working on this. My thoughts were to always look at writing a shader to simulate the camera distortion effect, but I've been concerned this full-screen post processing effect will be a resource hog and might stop the sim working on low-end systems.

So I've been re-experimenting attempting to get the FOV better with the simulated lens. I found that if I modelled a physical camera lens sensor to a 1/3" (as used in many FPV cameras) I start to get better results - although I did find I needed to alter the way the Y part of the sensor was shaped (else things look too squashed) and it still feels as though the camera sank back, so in order to stop showing the motors I have initially move the camera slight up and forwards.

By comparing what I had originally, I concluded that the default view was approximately equivalent to a 2.8mm lens. In the new view this won't show any of the props

Screenshot 2020-06-12 at 11 51 30

Rather than being able to change to a certain FOV, the current implementation allows you to cycle through common lenses: 2.8mm, 2.1mm, 1.8mm and 1.66mm

Screenshot 2020-06-12 at 11 51 08

Screenshot 2020-06-12 at 11 51 16

Screenshot 2020-06-12 at 11 51 23

Not sure if these will stay as is, as there's more testing to do and I need to implement them on the network side of things as well.

CurryKitten commented 4 years ago

I think I'm happy with the way this works for now. In the future, I may bring in extra distortion, but it only seems to add overhead to the code. There's a slight issue in that when upside down, some of the display might get clipped - this is because the camera is floating slightly above the body of the quad to look good. I think this is an acceptable trade-off though