Solution: Foliage & HierarchicalInstancedStaticMesh stuck at last LOD with master 4.15

A quick test:

Create a map with a StaticMesh with LODs like KiteDemo/HillTree_Tall_02 on the left and a foliage painted version of the mesh on the right. Turn on View Mode/Level of Detail Coloration/Mesh LODs. Zoom in and out. In master 4.15 as of 12/2/2016, the foliage painted version (HierarchicalInstancedStaticMesh) on the right is stuck at the last LOD.

Studying the source closely, the following changed formula is the problem:

Engine\Source\Runtime\Engine\Private\HierarchicalInstancedStaticMesh.cpp:
float Fac = View->GetTemporalLODDistanceFactor(SampleIndex, bMultipleSections) * SphereRadius * LODScale;

Engine\Source\Runtime\Engine\Private\InstancedStaticMesh.cpp:
float Fac = View.GetTemporalLODDistanceFactor(SampleIndex) * SphereRadius * LODScale;

Before git commit 11/1/2016, both SphereRadius and LODScale were squared:
float Fac = View->GetTemporalLODDistanceFactor(SampleIndex, bMultipleSections) * SphereRadius * SphereRadius * LODScale * LODScale;

Restoring all appearances of the formula (2 lines in HierarchicalInstancedStaticMesh.cpp, 1 line in InstancedStaticMesh.cpp) brings back the old behavior. However, as you can still see from the LOD visualization test, the old behavior is far from perfect.

It turns out, LODScale float is directly retrieved from the console variable “foliage.LODDistanceScale” with default 1.0f. Keeping the new formula and setting foliage.LODDistanceScale 20000 gives a much closer approximation to the regular StaticMesh LOD switching with zoom on the left. Perhaps, that is what the developers are eventually aiming for.

Hi Büke,

I just checked in a fix for this for 4.15, although I think it’s missed the Preview 1 cutoff so it’ll be in Preview 2. The change is here:

There were some major changes to the screen size calculation for regular static mesh LOD which broke HISMC, so the entire HISMC foliage calculation needed reworking.

Cheers

I just checked in a fix for this for 4.15, although I think it’s missed the Preview 1 cutoff so it’ll be in Preview 2. The change is here:

There were some major changes to the screen size calculation for regular static mesh LOD which broke HISMC, so the entire HISMC foliage calculation needed reworking.

Cheers

[/QUOTE]

I apologize for the delayed notification. We have noticed and thank you very much for your fix!