[4.7.6] Changing FOV causes DistanceField Shadowing to flicker.

Hi guys,

We’re currently using Distance field shadowing in-game.
Our camera when rotated to look upwards causes a slight FOV change for an aesthetic effect.

The further upwards we point the camera, the higher the FOV becomes.

Because of this, we’ve noticed that the DistanceField shadows seem to flicker, or “switch off” for a frame when the FOV is constantly changed.

You can see the issue in the video Here.

I have found a temporary work-around which is to increase the “DistanceField Shadow Distance.”

This fix is not ideal however as the issue seems to be resolution dependent. The higher the resolution the larger the distance needs to be to counter the bug.

We are very shortly going to be releasing the game to the public, so I was wondering if there was a fix for this in 4.8/4.9, and if so, what change would that be so we can integrate that specific changelist before launch (If possible)

Cheers.

Hi FacePalm.exe,

Thank you for the report. We have assigned one of our technicians to investigate your issue and they may post here with additional questions or comments.

Hey FacePalm,

If you would create another video with the same scene and go to view show > visualize > Mesh Distance fields and record if it is flickering there.

Also if you could show the AO Shadows.

Lastly what is your Mesh Distance Field set to. If those buildings are outside of that range then the computation by default switches back to cascading shadows that have a limited range on them.

Thanks,

Hey ,

I’ve created another video here.
This has the “DistanceField AO” visualization, and then the “Mesh Distance fields” visualization.

The Mesh Distance fields do indeed flicker. This is only on smaller meshes however.

Where is the value set for the “Mesh Distance Field?” Is that the resolution set per mesh? (Which is set to 1.0f on almost all our meshes) the DistanceFieldShadowDistance value set on the directional light? (30000.0f causes flickering ~60000.0f does not) or the OcclusionMaxDistance value set on the Skylight Actor? (Set to 600.0f, and cannot be changed.) Or is there another value somewhere that I’m missing?

Cheers.

After digging further, this seems to be possibly related to frustum size.

In another video found here, I’m increasing and decreasing the FOV. At a certain point as the FOV and frustum become narrower, the flickering starts.

Hope that helps a bit.

Hey FacePalm,

In regards to the mesh distance fields this would be handled inside of your meshes on your LOD’s.

Steps to recreate :

1.) Locate a mesh that you are experiencing this issue with.
2.) Double click that object in your content browser to bring up that meshes information window.
3.) On the right side under Details there will be a LOD section.
4.) In that section there is another roll out menu for Build Settings.
5.) Down at the bottom there is a tab called Distance Field Resolution Scale.
6.) On the larger objects you may be able to get away with number like 3.0. ( I wouldn’t recommend going any higher as it increases draw time.)
7.) As an alternative you may eliminate the scale with a value of 0. This is usually done with grass and small foliage.

Many of these preferences work in optimization workflows and it will be different for different games.

Finding what works best for you will require some tweaking,

Hope this helps,

Cheers for the info, however this doesn’t fix the issue. (I tried setting objects to 3+ vales and generally having a play around with the value)

As mentioned above this isn’t so much an issue with the Mesh DistanceFields, but specifically with the DistanceField shadowing.

When the frustum size is changed (Particularly via a FOV change) the DistanceField shadowing breaks for a frame across the ENTIRETY of the scene. (Not just a specific set of meshes) This seems as though the Distance field shadows don’t get calculated correctly/at all before the initial render after the size changes.

Hey FacePalm,

DistanceField meshes are how DistanceField shadows are calculated.

There are limitations with everything including shadows and DistanceField.

If you could recreate this in a test project in a later build. Like 4.8. I know that the performance of DistanceField AO especially has been improved by up to five times in the preview of 4.9.

At this point this is not a bug because you are able to slightly improve this issue with a FOV change.

With the limitations of the current version of UE4 that you are using I would highly recommend testing this out and seeing if that fixes it.

I will be moving this thread from Bug reports to Rendering,

Thanks,

Hey again .

So this issue is in both 4.8.3 and the 4.9.0 preview.

I’ve created a test project in both branches and when DistanceField’s and DistanceField shadowing is switched on, the flicker happens.

And with the “able to slightly improve this issue with a FOV change”; Not being able to change the FOV to under 90° is not a solution.

Here is a video of it happening in the FPS test project (Sorry about the music, only realized it captured after uploading)

And here is a dropbox link to the 4.8.3 project which reproduces the issue.

Use the scroll-wheel to rapidly change the FOV to reproduce the issue.

I’d appreciate it if this was moved back to the bug report section, as it’s still a bug.

Hey FacePalm,

I took your test project and then opened that project in 4.8.3.

I recorded a movie of the results and uploaded it to Youtube.

I did not experience the same issue that you are.

If you would link me your dxDiag,

I can see if there is any reported issues or documentation on compatibility between your machine and Distance Field Shadows.

Thanks,

Hey FacePalm,

After pulling in some other people on this issue. I would still like your DXDiag but see if this command solves the issue.

r.dfshadowScatterTileCulling 0

Let me know what you find out,

Hey ,

Firstly the issue is when you’re in PIE or game. The scrollwheel only moves the Editor camera forwards and backwards when not in PIE. (In your video you don’t seem to be in PIE mode)

The FOV change is inside the FirstPersonCharacter BP, which is:

My DXDiag is attached [here.][2]

Setting r.dfshadowScatterTileCulling to 0 does work for the 4.8.3 test project, however it completely breaks DF shadowing in our 4.7.6 game. Video of the results [here][3]

Were there any other possible work-arounds I could try in 4.7.6?

EDIT: We’ve just finished the initial upgrade to 4.8.2 (It’s been in the works for a while) and the r.dfshadowScatterTileCulling 0 change seems to cause all our speedtrees to start flickering in the distance.

Cheers dude.

Hey FacePalm,

In your original project. Have your objects been scaled non uniformly? For instance if you have an x value of 1 a y value of 2 and a z value of 1.

If you are using mesh distance fields then this could cause issue. Mesh distance is calculated by a power of two.

If you have a value that is set between the calculation then there is clipping issues that occur.

Thanks,

Hey FacePalm,

I haven’t heard from you in a few days. I was wondering if you were still experiencing this issue?

Thanks,

Hey FacePalm,

Due to inactivity and tracking issues, I will be marking this thread as answered. If you would test the above mentioned post and see if anything is scaled non uniformly.

I was never able to recreate this issue even with speed tree models inside of the test you sent me.

If you are still experiencing this issue then please comment again and I will continue to investigate at that time.

Thanks,

Hey ,

We were in the middle of shipping, and have gone into support mode currently. :stuck_out_tongue:

Answering your question: There are some items which are non-uniformly scaled in the scene, however the flicker/artifacts are also present on objects which are uniformly scaled as well.

Does this mean we can’t have ANY object in the scene which is non-uniformly scaled, or that flickering/artifacts should ONLY appear on the non-uniformly scaled objects?

Cheers.

Hey FacePalm,

Not necessarily. However, distance fields are calculated by a power of two. So the calculations will occur at 2, 4 ,6 respectively.

So if you have scaled your mesh to a power of say X = 1.3 Y = 2 and Z = 2 then the distance fields will essentially try to draw or calculate what value it’s closest to. Sometimes this can cause issue when calculating the distance field because UE4 is not sure which value to associate 1.3 to and therefore could cause artifacting and the graphical glitches that you are experiencing.

Thanks,

So I removed all non-uniformly scaled objects in the level (Foliage, etc)
And am still seeing the same issue when “r.dfshadowScatterTileCulling 0”

It seems it’s related to the number of objects in the level. the more meshes in the level, the larger the number of errors that occur (Even with uniformly scaled objects.)

Hello FacePalm,

Without your game/project in front of me I cannot look into this issue any further.

I have exhausted all Ideas and the ideas of other support technicians.

Right now I am working on procuring a copy of submerged and I will be able to have eyes on the actual project.

I will get back to you as soon as I do.

Thanks,

If you’re grabbing a retail copy, we have switched off Distance Fields in the retail build due to the flickering issues.

You’ll need to get in contact with the guys to get a build with Distance Fields.

Sorry I couldn’t be more helpful. :frowning: