Landscape mesh reduction and line traces against landscape

Hi all, I’ve encountered an issue positioning dynamic spatial UI meshes on the landscape. These meshes are dynamic and spawned as part of the UI (e.g. under the mouse cursor as the cursor moves around on the landscape). In some cases when the camera is far away, the meshes partially or fully disappear under the landscape. I use line traces downwards to get the height at a given point on the landscape.

It’s not caused by Z-fighting, but seems to be caused by the mesh reduction of the landscape as the camera moves away from it, as the reduced geometry could end up being higher (or lower) than the LOD 0 height at that XY location. If I force the landscape to always render at LOD 0, the issue goes away.

I’ve seen that I can set the collision LOD level for both complex and simple collision testing, as explained by this article: Landscape Collision Guide in Unreal Engine | Unreal Engine 5.6 Documentation | Epic Developer Community

But, what I seem to need is for the line trace to use the actual geometry that is rendered, which is potentially a blend between LODs. Always using the min LOD or max LOD for example doesn’t work, since the rendered geometry may be higher, which will hide my mesh.

The landscape - just like anytjing - has LODs.

If you trace and its an LOD0 that is traced you have no guarantee that the values you get are accurate compared to what is on screen.

Like you actually discovered and listed below.

You don’t really have a way out of this.

Best you could do is try if somehow a line trace is able to tell you what LOD is being returned.

The docs are completely useless on this.

Try to get the Hit Component off a break hit result, and dig into what options you have in there.

In theory when you trace to the landscape you always get a response of a hit component (because that’s how the landscape is made).

The question you have to answer is if within that hit result you already have the LOD value avaliable or if you need to c++ your way to it.

If so, from the component you get the mesh, from the mesh you get the LOD by re-doing the same calculation driven by the size on screen of the mesh.

An alternative may be to get the component, get its bounding box size and run the calcs based on that - just remeber that you need to actively read the settings for the landscape which can change from map to map if you stick with landscapes.

Ps: another reason why the landacape working its LODs as a sizeonscreen is a horrible idea.

PPS: you could always do the right thing for any game and stop using landacapes :wink: Finding the LOD of a mesh directly is probably a lot easier.