2
\$\begingroup\$

After adding a first-personal controller asset, world shadows flicker like crazy. I don't understand the cause, and everything I've tried based on googling has failed to help.

https://i.imgur.com/Mx5MCKB.gifv

I've tried:

  • Increasing the near clipping plane of the camera. The first-person asset I have defaults to 0.01. Changing it to 0.1 or higher seems to solve the issue, except that breaks the first-person view.
  • Toying with bias value on the directional light
  • Changing Render Mode from Auto to Important on the directional light
  • Changing the Shadow Projection quality to Stable Fit

The authors of the asset have not been able to help, though it doesn't seem to be specifically related to their product, just the clipping planes required.

I'm using Unity 2019.1.2f1 Personal.

\$\endgroup\$
  • \$\begingroup\$ How far are you from the origin here? And in what specific way does the first-person view "break" when adjusting the near plane? \$\endgroup\$ – DMGregory May 13 at 16:38
  • \$\begingroup\$ Around 1000 meters. The FPC asset uses two cameras. Camera -> First Person Camera. When I first changed the near clipping plane, it was on the First Person camera. That fixed the issue, but the "arms" of my character were no longer visible (or weren't all visible). However, by changing the near clip plane of only the parent camera, the flicker goes away and the first person view seems unaffected. I could have sworn I tried that, but it seems to work. I need to better understand why they have two cameras though. The first seems to be for terrain/UI and the second for world objects. \$\endgroup\$ – BotskoNet May 13 at 16:45
  • \$\begingroup\$ Sounds like you can post that solution as an answer. The reason for the two cameras is that you generally want precision meters to kilometers away when rendering the world around you, and precision centimeters away when rendering your character's arms/tools. You can use layers to filter the content seen by each camera to ensure the "body cam" doesn't impact the rendering of objects other than your character's own body. The other benefit of using two cameras is you can clear the depth buffer after the first so you never see arms/tools clip into nearby obstacles. \$\endgroup\$ – DMGregory May 13 at 16:50
  • \$\begingroup\$ Also, beware that past 1000 m, you have about 8x the rounding error that you have within 200 m of the origin, which might be enough to start causing noticeable rounding errors or jitter in certain chains of lossy operations. The more you can keep your gameplay close to the origin, the more consistent your results will tend to be. \$\endgroup\$ – DMGregory May 13 at 16:59
1
\$\begingroup\$

The first person asset uses two Camera objects, a Camera and a First Person Camera. Both had the Near Clipping Plane set to 0.01. Changing that value on the root Camera object solved the flicker, and did not interfere with the First Person Camera's view of the character arms.

The "Camera" object:

enter image description here

The "First Person Camera" child object:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ You might want to pull the far plane value on the First Person Camera closer. It's doubtful that you'd need to render your character's arms 1000 m away. ;) \$\endgroup\$ – DMGregory May 13 at 17:18
  • \$\begingroup\$ Good idea, thanks. These values are pretty much the defaults, I haven't gone through to really clean things up (I'm still using the demo character too). I misunderstood which camera was the "primary" camera previously so I need to tweak some things first (mainly my vegetation, it renders to the first person camera) \$\endgroup\$ – BotskoNet May 13 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.