EntroPi-Games / GPU-Line-of-Sight

GPU Line of Sight / Field of View visualization for Unity
Apache License 2.0
129 stars 24 forks source link

Moire pattern after upgrading from 1.1 to 1.4.2 #1

Open fastict opened 3 years ago

fastict commented 3 years ago

Hi, we have an older codebase using version 1.1. After upgrading to 1.4.2, we're seeing a moire pattern instead of a solid color. See the attached sshots of before / after. Any ideas why this would happen? los-1 1 los-1 4

EntroPiGames commented 3 years ago

Have you tried increasing the render texture resolution for the LOS source or changing the Min Variance property?

fastict commented 3 years ago

Hi @EntroPiGames, thanks for the response!

Changing the 'Render Target Width' and 'Height' had no effect. It was set to 512, I tried different values up to 4096.

Changing the 'Min Variance' makes the pattern less noticeable, but it doesn't go away completely. It was set to 0.1, and moving the slider to 1.0 gives the sshot attached. Is it possible to override the slider bar and go over 1.0 and get better results?

Any other suggestions?

Thanks!

gpu-line-of-sight-03

EntroPiGames commented 3 years ago

A couple of other things you could try:

You can change the range of the slider by increasing the second value of this range attribute.

fastict commented 3 years ago

I ended up increasing the Min Variance to 10 and that improved it almost to the point where we were with version 1.1 Any downsides to increasing the value to 10? Any performance issues or inaccuracies in doing this?

Thanks again for your help.

EntroPiGames commented 3 years ago

The downside of increasing the Min Variance property is that you lose accuracy.

I've finally had some time to run some test, and I think I know what might be causing the moire pattern / banding in this case.

If the distance between the near and far clipping plane of your main camera is too large, the depth buffer (which is used to reconstruct the world position in the LOSMask shader) loses accuracy, which causes the banding.

So to solve this issue, either reduce the far clipping plane, or increase the near clipping plane of your main camera. The goal is to keep the distance between both as small as possible.

Here's an example. The far clipping plane in the top image is set to a 1000, and to 10000 in the bottom one. All other properties are identical.

LOS-Terrain