LOD Camera and Terrain

Weird Issue

I noticed an issue with the LOD and the camera, sometimes this happens when a section of the quad stops rendering. I’m using a FlyCamera. What’s causing this?

Might be a good idea to tell us the dimensions of your terrain.
This is (I think) known to happen when you do stuff on a microscopic scale.

It’s impossible to tell without code. Remove the Lod control and see if it replicates. Enable wireframe mode using material.getAdditionalRenderState().setWireFrame(true); to see what’s happening.

Failing that, a good old log debug usually suffices. Of course a keen eye and some code would also do the trick :slight_smile:

What’s the issue, exactly? The patch disappearing on bottom-right?

Yes, that section on the bottom disappears. This happens especially when I get close to the mesh and look up but no matter how close or far the camera is this problem happens and it doesn’t matter how big or small the terrain is either. Zooming the camera out helps though.
But the terrain is setup with the following (This isn’t the exact code though)

totalSize = 513 // Is that too small?
patchSize = 65

terrain.setLocalTranslation(0, -50, 0);
terrain.setLocalScale(2f, 1f, 2f);

// When I remove this the problem still exists.
control.setLodCalculator(new DistanceLodCalculator(getPatchSize(), 1.5f));

Might be a frustum calculation error.

It doesn’t look too much like an error, it’s when the bottom of the camera moves over the mesh causing it to no longer render.
I was thinking maybe I could adjust that? I just don’t know where to look. The camera, the LodControl?

Weird Issue 2

Here is another image with a wireframe and I drew two white lines. The max draw distance and the line I think is causing the issue (the bottom of the camera)

This next image is in wireframe viewing the whole surface without that issue, one more level of detail can be drawn if I get closer.

Weird Issue 3

Did you made your terrain with the Terrain editor or is it generated another way?

The Terrain Editor automatically creates a the LOD control and DistanceLodCalculator that you’ll notice if you view the Terrain’s children in the scene composer. I’ve found that if I forget to remove this control, then I get similar results as you when I try to add another LOD control with code.

It’s through code, it has to be, it’s a dynamic mesh that changes

Maybe you could provide a simple test case. Preferably one single class that illustrates the issue.

Not sure why I would do that. I don’t even know where to begin.
It appears that the LOD setting is stopping the rendering of a patch when the camera’s line of sight crosses the midpoint of the patch at the bottom of the screen. It’s very apparent when I get close to the mesh and look up.
So again, I can only really test this through actual usage and not testing code, cause again I don’t even know where to begin with that.

This could be caused by an improper bounding volume for that terrain patch maybe?

Like @aegroto mentioned,

Since you mentioned that when you remove the LOD control the problem is still there, then it sounds like it’s most likely an issue with the frustrum calculation.

Does it happen on every terrain patch, or is it happening at just that one specific patch in the terrain?

Yes, every patch is affected. Zooming the camera out helps but not completely.

The fact the zooming the camera out helps convince me even more that it is something about wrong culling. Have you modified FlyCamera or anything related to it?

When objects don’t appear on screen when they should but then suddenly appear when you look in a certain direction, I would bet good money that the bounding shape was not refreshed after the data was changed.

Just an update, I did remove LOD and the surface works fine and this problem doesn’t exist. I made the surface a bit larger and the camera doesn’t cut off the surface anymore :s